-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-branch-date
executable file
·73 lines (65 loc) · 1.67 KB
/
git-branch-date
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
#!/bin/bash -
#===============================================================================
#
# File: a.sh
#
# Usage: ./a.sh
#
# Description:
#
# Options: ---
# Requirements: ---
# Bugs: ---
# Notes: ---
# Author: ShadowStar, <[email protected]>
# Organization: Gmail
# Created: 06/09/16 03:03:11
# Last Change: 06/09/16 04:02:04
# Revision: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
export LC_ALL=en_US.UTF-8
REFS="refs/heads refs/remotes"
COMMIT=
usage () {
echo "Usage: $0 [-a|--all] [-t|--tags] [<contains id>]"
echo " -a|--all -- show all refs"
echo " -t|--tags -- show tags instead of branches"
echo " <contains id> -- only list refs which contain specify commit"
exit -1
}
[ $# -le 4 ] || usage
until [ $# -eq 0 ]; do
case "$1" in
-a|--all)
REFS=refs/
shift ;;
-t|--tag|--tags)
REFS=refs/tags
shift ;;
-*)
usage ;;
*)
COMMIT="--contains $1";
shift ;;
esac
done
fmt='
red=%(color:red)
green=%(color:green)
yellow=%(color:yellow)
blue=%(color:blue)
cyan=%(color:cyan)
reset=%(color:reset)
a=%(authorname)%(*authorname)
n=%(refname)
d=%(committerdate:iso)%(*committerdate:iso)
s=%(subject)
S=%(objectname:short)
b=${n#refs/heads/}
u=%(upstream)
H=%(HEAD)
echo "${red}${H/\*/${green}*} ${b#refs/}${reset}${u/*/ [${blue}${u#refs/remotes/}${reset}]} <${yellow}$a${reset}@${yellow}$d${reset}> ${cyan}$S${reset} $s"
'
eval=`git for-each-ref --shell --format="$fmt" ${REFS} ${COMMIT}`
eval "$eval" | sort -t@ -k2 -r