diff options
Diffstat (limited to 'build-aux/git-hooks')
-rwxr-xr-x | build-aux/git-hooks/commit-msg | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg index 39450865cb8..e1ff281de71 100755 --- a/build-aux/git-hooks/commit-msg +++ b/build-aux/git-hooks/commit-msg @@ -44,7 +44,7 @@ if test "$at_sign" != @; then fi # Check the log entry. -exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" ' +exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" ' BEGIN { # These regular expressions assume traditional Unix unibyte behavior. # They are needed for old or broken versions of awk, e.g., @@ -66,8 +66,12 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" ' non_print = "[^[:print:]]" } } + c_lower = "abcdefghijklmnopqrstuvwxyz" + unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org" } + { input[NR] = $0 } + /^#/ { # Ignore every line after a scissors line. if (/^# *---* *(>[8%]|[8%]<) *---* *$/) { exit } @@ -125,6 +129,10 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" ' status = 1 } + $0 ~ unsafe_gnu_url { + needs_rewriting = 1 + } + $0 ~ non_print { print "Unprintable character in commit message" status = 1 @@ -135,6 +143,21 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" ' print "Empty commit message" status = 1 } + if (status == 0 && needs_rewriting) { + for (i = 1; i <= NR; i++) { + line = input[i] + while (match(line, unsafe_gnu_url)) { + prefix = substr(line, 1, RSTART - 1) + suffix = substr(line, RSTART) + line = prefix "https:" substr(suffix, 5 + (suffix ~ /^http:/)) + } + print line >file + } + if (close(file) != 0) { + print "Cannot rewrite: " file + status = 1 + } + } if (status != 0) { print "Commit aborted; please see the file 'CONTRIBUTE'" } |