-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-recent
executable file
·33 lines (26 loc) · 1.04 KB
/
git-recent
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
recent() {
refbranch=$1
count=$2
git \
for-each-ref \
--sort=-committerdate \
refs/heads \
--format='%(refname:short)|%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' \
--color=always \
--count=${count:-20} | \
while read line; do
branch=$(echo "$line" | awk 'BEGIN { FS = "|" }; { print $1 }' | tr -d '*')
ahead=$(git rev-list --count "${refbranch:-origin/dev}..${branch}")
behind=$(git rev-list --count "${branch}..${refbranch:-origin/dev}")
colorline=$(echo "$line" | sed 's/^[^|]*|//')
echo "$ahead|$behind|$colorline" | \
awk -F'|' -vOFS='|' '{$5=substr($5,1,70)}1';
done | \
( echo -e "ahead|behind||branch|lastcommit|message|author\n" && cat) | \
strip.pl |\
tr '|' ',' | \
tr -s ',' |
xsv table
# column -ts'|';
}
recent $@