-
Notifications
You must be signed in to change notification settings - Fork 0
/
srcdirs
executable file
·42 lines (38 loc) · 953 Bytes
/
srcdirs
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
#!/usr/bin/env bash
#
# srcdirs
# all git repos in $1 with config attribute $2 == 'true' printed
#
# dirties
# outputs all srcdirs that have any 'modified' statuses
#
# note:
# - does not handle spaces in repo paths (and newline is OFS)
# - works only with non-bare repositories
# - default basedir ~/src
# - default pubattr 'srcdirs.ispublic'
#
# scott@smemsh.net
# https://github.com/smemsh/utilsh/
# https://spdx.org/licenses/GPL-2.0
#
##############################################################################
if [[ ${0##*/} == dirties ]]
then for dir in `srcdirs`
do git -C $dir diff --quiet || echo $dir; done; exit; fi
basedir=${1:-~/src}
pubattr=${2:-'srcdirs.ispublic'}
for dir in $(
find $basedir/ \
-mindepth 2 \
-maxdepth 2 \
-type d \
-name '.git' \
); do
basedir=${dir%.git}
basedir=${basedir%/}
ispublic=$(git -C $basedir config --get --bool $pubattr)
[[ $ispublic == 'true' ]] &&
echo "$basedir"
done
true