unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 1dd89dcdea054c84f708d67c5df148437fa89575 1082 bytes (raw)
name: build-aux/git-hooks/commit-msg-files.awk 	 # note: path name is non-authoritative(*)

 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
}

debug log:

solving 1dd89dcdea0 ...
found 1dd89dcdea0 in https://yhetil.org/emacs-devel/48d4dffa-cfa8-7949-3043-a1efa937902d@gmail.com/

applying [1/1] https://yhetil.org/emacs-devel/48d4dffa-cfa8-7949-3043-a1efa937902d@gmail.com/
diff --git a/build-aux/git-hooks/commit-msg-files.awk b/build-aux/git-hooks/commit-msg-files.awk
new file mode 100644
index 00000000000..1dd89dcdea0

Checking patch build-aux/git-hooks/commit-msg-files.awk...
Applied patch build-aux/git-hooks/commit-msg-files.awk cleanly.

index at:
100644 1dd89dcdea054c84f708d67c5df148437fa89575	build-aux/git-hooks/commit-msg-files.awk

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).