-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscan-git-repos
executable file
·35 lines (29 loc) · 1.09 KB
/
scan-git-repos
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
#!/usr/bin/env bash
################################################################################
# scan-git-repos - given a directory tree that contains git repos, this script
# will find the repos and display information about their state.
#
# Version 3
# Matthew Malensek <matt@malensek.net>
################################################################################
for repo in $(find . -name '.git'); do
parent="${repo%/*}"
num_commits=$(git -C "${parent}" log --branches --not --remotes \
--simplify-by-decoration --decorate --oneline | wc -l)
num_changes=$(git -C "${parent}" status -s | wc -l)
# git -C "${parent}" ls-remote
if (( num_commits == 0 && num_changes == 0 )); then
continue
fi
echo "-- ${parent} --"
if (( num_commits > 0 )); then
echo "Commits (${num_commits}):"
git -C "${parent}" log --branches --not --remotes \
--simplify-by-decoration --decorate --oneline
fi
if (( num_changes > 0 )); then
echo "Changes (${num_changes}):"
git -C "${parent}" status -s
fi
echo
done