-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgsall
More file actions
executable file
·135 lines (120 loc) · 4.56 KB
/
gsall
File metadata and controls
executable file
·135 lines (120 loc) · 4.56 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
#set -x
source ./functions.sh
source ./.fork-config
diffOrStat() {
COMMAND=$1
if [[ -z $COMMAND ]]; then
echo "diffOrStat requires a command"
exit 1
fi
DIFF_SIZE=$(eval git $COMMAND -U0 --no-prefix | grep -v "^+++" | grep -v "^diff --git" | grep -v "^index " | wc -l)
if [[ $DIFF_SIZE -lt 50 ]]; then
set -x
# echo "DIFF ----------------"
eval git $COMMAND -U0 --no-prefix | grep -v "^+++" | grep -v "^diff --git" | grep -v "^index "
cat
else
STAT_CMD="$COMMAND --stat"
STAT_SIZE=$(eval git $STAT_CMD | wc -l)
if [[ $STAT_SIZE -lt 10 ]];
then
# echo "STAT verbatim ----------------"
eval git -c color.ui=always $STAT_CMD |
grep -v "files changed" |
cat
else
# echo "STAT trimmed ---------------"
# should show just the stat summary, and not the diff.
# assume the COMMAND was `git stash show`, which takes diff options.
eval "git -c color.ui=always $STAT_CMD --no-patch --stat --stat-count=7" |
cat
fi
fi
}
showGraphVs() {
first=${1:-main}
second=${2:-refs/remotes/${UPSTREAM_REMOTE_NAME:-upstream}/main}
# git -c color.ui=always log --graph --abbrev-commit --oneline --decorate --boundary HEAD..origin/main
git -c color.ui=always log --graph --abbrev-commit --oneline --decorate --all --boundary ${first}..${second} --
}
showStatus() {
{
# git -c color.ui=always status --short -b
RESULTS=$({
git -c color.ui=always status --show-stash --no-ahead-behind |
grep -v "Your branch is up to date with" |
grep -v "no changes added to commit" |
grep -v "Changes not staged for commit" |
grep -v "working tree clean" |
grep -v "what will be committed" |
grep -v "ahead-behind" |
grep -v "modified:" |
grep -v "to discard changes in working directory" |
grep -v "git restore --staged" |
grep -v "^On branch" |
grep -ve "^\s*$" |
cat
#echo "--- stash" >&2
STASH_COUNT=$(git stash list | wc -l)
if [[ $STASH_COUNT -gt 0 ]]; then
diffOrStat "stash show --patch" | while read line; do
echo " stash> $line"
done
fi
#echo "--- diff" >&2
DIFF_CMD='git diff -U0 --no-prefix | grep -v "^+++" | grep -v "^diff --git" | grep -v "^index " '
DIFF_SIZE=$(eval $DIFF_CMD | wc -l)
# get the current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# echo "--- graph size" >&2
GRAPH_SIZE1=$(showGraphVs main | wc -l)
# GRAPH_SIZE2=0
# if [[ $BRANCH != "main" ]]; then
# GRAPH_SIZE2=$(showGraphVs $BRANCH main | wc -l)
# fi
if [[ $GRAPH_SIZE1 -gt 0 || $DIFF_SIZE -gt 0 || $BRANCH != "main" ]]; then
if [[ $GRAPH_SIZE1 -gt 0 ]]; then
# echo " ----------------- show graph" >&2
showGraphVs main
echo " -----------------"
fi
git -c color.ui=always branch -vv |
egrep --color=never "^\\*|ahead|behind"
echo -e "${YELLOW}On branch ${BLUE}${BRANCH}${NC}"
else
git -c color.ui=always branch -vv |
egrep --color=never "ahead|behind"
fi
# echo "- c"
# echo "--- diff size" >&2
if [[ $DIFF_SIZE -lt 30 ]]; then
eval $DIFF_CMD
# echo "-- diff"
else
STAT_CMD='git -c color.ui=always diff --stat'
STAT_SIZE=$(eval $STAT_CMD | wc -l)
if [[ $STAT_SIZE -lt 10 ]]; then
# echo " --- git diff-stat" >&2
eval $STAT_CMD |
grep -v "files changed" |
cat
else
# echo " --- git diff-short-stat" >&2
eval "$STAT_CMD --stat-count=7" |
cat
fi
fi
})
[[ -z $RESULTS ]] || {
echo "$RESULTS"
echo "--------------------------------------------------"
}
} | labeledOutput $LABEL
}
{
eachRepo parallel buffered "checking \`git status\` in each repo" \
showStatus $*
} | optionalPager
echo >&2
echo "run ./need-commits to see a list of repos needing commits" >&2