-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgith-ignore
executable file
·72 lines (48 loc) · 1.68 KB
/
gith-ignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
echo ""
echo "EasyNOMP Adding to GitIgnore..."
echo ""
source ~/.bashrc
source /etc/os-release
## who am i? ##
SCRIPTNAME="$(readlink -f ${BASH_SOURCE[0]})"
BASEDIR="$(dirname $SCRIPTNAME)"
GITPRJDIR=$(git rev-parse --show-toplevel)
RELIN=$(realpath --relative-to="${GITPRJDIR}" "${1}")
## Okay, print it ##
echo "Script name : $SCRIPTNAME"
echo "Current working dir : $PWD"
echo "Script location path (dir) : $BASEDIR"
echo "Git repo location path (dir) : $GITPRJDIR"
echo "INPUT: ${RELIN}"
echo ""
if [ ! -z $GITPRJDIR ]; then
# Add to git ignore
# echo "I coufile [${PWD}/.git] to add [${1}] to!";
if [ -e ${GITPRJDIR}/.gitignore ]; then
if [ "${PWD}" != "$GITPRJDIR" ]; then
# Add to git ignore
echo "${RELIN}" | tee -a ${GITPRJDIR}/.gitignore > /dev/null
echo "I successfully added [${RELIN}] to the file [${GITPRJDIR}/.gitignore]!";
else
# Add to git ignore
echo "${1}" | tee -a ${GITPRJDIR}/.gitignore > /dev/null
echo "I successfully added [${1}] to the file [${GITPRJDIR}/.gitignore]!";
fi
else
if [ "${PWD}" != "$GITPRJDIR" ]; then
# Add to git ignore
echo "I couldn't find the file [${GITPRJDIR}/.gitignore] to add [${RELIN}] to!";
else
# Add to git ignore
echo "I couldn't find the file [${GITPRJDIR}/.gitignore] to add [${1}] to!";
fi
fi
else
# Add to git ignore
echo "This location [${PWD}] is not inside of a git repo!";
fi
echo ""
echo "Done!"
echo ""
exit 0