-
Notifications
You must be signed in to change notification settings - Fork 9
/
git-update-all
executable file
·48 lines (42 loc) · 1.41 KB
/
git-update-all
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
#!/bin/bash
# sort of like svn-update-all
declare WORKDIR="${1:-.}"
pushd "${WORKDIR}"
curbranch="$(git rev-parse --abbrev-ref HEAD)"
if [[ x"$curbranch" == xunknown ]]; then
echo Unable to determine current branch
exit 1
fi
# Delete _explicitly_ ignored files (-X)
git clean -dfX
# CHECK: Are there new .c, .h, or .cpp files I forgot to add?
# NTS: TODO improve regex here, perhaps with -E
x=`git clean -n -d {,*/,*/*/,*/*/*/,*/*/*/*/}*.{c,cpp,h,sh,pl,latex,png,jpg,jpeg,version-t,js} | sed -e 's/^Would remove //'`
if [[ x"$x" != x ]]; then
(echo 'Did you forget to add new source files?'; echo 'Quit this pager, then answer the question'; echo '---------------------------'; echo $x) | less
echo "Confirm whether or not you want to add the source files."
echo 'Type YES to add them, NO to delete them, anything else to quit'
read X
if [[ "$X" == "YES" || "$X" == "yes" ]]; then
for xx in $x; do
git add "$xx" || exit 1
done
else
if [[ "$X" == "NO" || "$X" == "no" ]]; then
echo "Files will be deleted by git upon cleanup stage. Hit CTRL+C to abort now if you don't want that"
read TMP
else
echo "Exiting now."
exit 0
fi
fi
fi
make clean 2>/dev/null
make distclean 2>/dev/null
"$(dirname "$0")"/cleantree 2>/dev/null
for i in \* \*/\* \*/\*/\*; do git add $i 2>/dev/null; done
git commit -a
"$(dirname "$0")"/cleantree 2>/dev/null
git push origin "$curbranch"
git pull origin "$curbranch"
git fetch