-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow-git-commit-summary
More file actions
executable file
·111 lines (88 loc) · 2.46 KB
/
show-git-commit-summary
File metadata and controls
executable file
·111 lines (88 loc) · 2.46 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
#!/bin/bash
typeset -i n_commits
st_hash=$1
en_hash=$2
git_path="$3"
# ---
if [ "${st_hash}" = "" -o "${en_hash}" = "" ]
then
echo "**Error** A start and end hash value are required, got '${st_hash}' and '${en_hash}'."
exit 1
fi
# ---
if [ "${git_path}" != "" ]
then
cd "${git_path}"
rc=$?
if [ ${rc} -ne 0 ]
then
echo "Can't change to directory '${git_path}', rc=${rc}"
exit 1
fi
fi
# ---
n_commits="$(git log "${st_hash}..${en_hash}" --no-merges --pretty='%H' | wc -l)"
#echo "Found ${n_commits} commits between hash '${st_hash}' and '${en_hash}'"
git log "${st_hash}..${en_hash}" --no-merges --graph --pretty='~~~ %d~~~ %H~~~ %aN~~~ <%aE>~~~ %s' \
| git name-rev --stdin \
| awk '\
BEGIN \
{
MAX_OUT_LEN = 200; # Something very large for now...
}
{
nparts = split( $0, parts, "~~~ ");
if( nparts != 6)
{
# out = $0;
out = "";
}
else
{
graph = parts[1];
sub( " $", "", graph);
decorate1 = parts[2];
sub( "^.*\\(", "", decorate1);
sub( "\\)$", "", decorate1);
gsub( "^ *", "", decorate1);
gsub( " *$", "", decorate1);
sub( "origin/master, ", "", decorate1);
sub( "origin/HEAD, ", "", decorate1);
sub( "^HEAD, ", "", decorate1);
sub( "^tags/", "", decorate1);
sub( "^remotes/", "", decorate1);
sub( "^origin/", "", decorate1);
sub( ", deploy$", "", decorate1);
short_hash = substr( parts[3],1,7);
decorate2 = parts[3];
sub( "^.*\\(", "", decorate2);
sub( "\\)$", "", decorate2);
gsub( "^ *", "", decorate2);
gsub( " *$", "", decorate2);
sub( "^HEAD, ", "", decorate2);
sub( "^tags/", "", decorate2);
sub( "^remotes/", "", decorate2);
sub( "^origin/", "", decorate2);
sub( ", deploy$", "", decorate2);
if( decorate1 != "" && substr(decorate2,1,length(decorate1)) != decorate1)
decorate = decorate1 " / " decorate2;
else decorate = decorate2;
author_name = parts[4];
author_email = parts[4];
author = author_name " " author_email;
commit_msg = parts[6];
# out = graph " " short_hash " " decorate ": " author ", " commit_msg;
# -- Simplified output to make cut-n-paste into deploy log easier
out = "* " commit_msg " (" short_hash ") " author_name;
if( length(out) > MAX_OUT_LEN) out = substr( out, 1, MAX_OUT_LEN - 3) "...";
}
if( out != "")
{
ncommit++;
printf "%s\n", out;
}
}
END \
{
if( !ncommit) printf "No changes found.\n";
}'