-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.git_bash_functions
executable file
·62 lines (60 loc) · 1.56 KB
/
.git_bash_functions
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
watch_repodir () {
local WATCHDIR
if [ "$1x" = "x" ]; then
WATCHDIR="$(pwd)"
else
WATCHDIR="$1"
fi
if [ -d "$WATCHDIR" -a -d "$WATCHDIR"/.git ]; then
grep -E "^$WATCHDIR\$" $HOME/.repowatchlist > /dev/null 2>&1 \
|| (echo "$WATCHDIR" >> $HOME/.repowatchlist && echo "Now watching $WATCHDIR")
else
echo "$WATCHDIR is not a directory or is not a git repository"
fi
}
unwatch_repodir () {
local repo
repo=$1
# Sed proved to be a PITA
grep -v -E "^${repo}$" $HOME/.repowatchlist > $HOME/.repowatchlist.tmp \
&& mv $HOME/.repowatchlist.tmp $HOME/.repowatchlist
}
find_uncommitted () {
if [ "$1"x = "--helpx" ]; then
echo "Usage: find_uncommitted [--debug]"
echo
echo "$HOME/.repowatchlist should contain a list of git repositories"
echo "(one path per line) to be checked for uncommitted changes."
return
fi
if [ "$1"x = "--debugx" ]; then
local DEBUG=1
else
local DEBUG=0
fi
if ! [ -f $HOME/.repowatchlist ]; then
echo "$HOME/.repowatchlist has no repositories to examine."
return 0
else
if [ $DEBUG -eq 1 ]; then
echo Watchlist:
cat $HOME/.repowatchlist
fi
fi
for i in `cat $HOME/.repowatchlist`
do
if [ $DEBUG -eq 1 ]; then
echo "Working on $i"
fi
if ! [ -d $i -a -d $i/.git ]; then
echo "$i not a directory or not a git repository, skipping"
continue
else
if [ $DEBUG -eq 1 ]; then
(cd $i; git status)
else
(cd $i; git status --short | (grep -E '^.+' > /dev/null 2>&1 && echo $i))
fi
fi
done
}