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
| | function get_commit_changes(commit_sha, changes, i, j, len, bits, filename) {
# Collect all the files touched in the specified commit.
while ((("git log -1 --name-status --format= " commit_sha) | getline) > 0) {
for (i = 2; i <= NF; i++) {
len = split($i, bits, "/")
for (j = 1; j <= len; j++) {
if (j == 1)
filename = bits[j]
else
filename = filename "/" bits[j]
changes[filename] = 1
}
}
}
}
function check_commit_msg_files(commit_sha, changes, good, msg, filename) {
get_commit_changes(commit_sha, changes)
good = 1
while ((("git log -1 --format=%B " commit_sha) | getline) > 0) {
if (! msg)
msg = $0
if (/^\* / && match($2, "[^:/][^:]*")) {
filename = substr($2, RSTART, RLENGTH)
if (! (filename in changes)) {
if (good) {
printf("In commit %s: %s\n", substr(commit_sha, 1, 10), msg)
}
printf(" File %s listed in commit message, but not in diff\n",
filename)
good = 0
}
}
}
return good
}
|