aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-hooks/commit-msg
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
-rwxr-xr-xbuild-aux/git-hooks/commit-msg27
1 files changed, 20 insertions, 7 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index e21aaf074c6..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
44fi 44fi
45 45
46# Check the log entry. 46# Check the log entry.
47exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" ' 47exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" '
48 BEGIN { 48 BEGIN {
49 # These regular expressions assume traditional Unix unibyte behavior. 49 # These regular expressions assume traditional Unix unibyte behavior.
50 # They are needed for old or broken versions of awk, e.g., 50 # They are needed for old or broken versions of awk, e.g.,
@@ -70,6 +70,8 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" '
70 unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org" 70 unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org"
71 } 71 }
72 72
73 { input[NR] = $0 }
74
73 /^#/ { 75 /^#/ {
74 # Ignore every line after a scissors line. 76 # Ignore every line after a scissors line.
75 if (/^# *---* *(>[8%]|[8%]<) *---* *$/) { exit } 77 if (/^# *---* *(>[8%]|[8%]<) *---* *$/) { exit }
@@ -127,12 +129,8 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" '
127 status = 1 129 status = 1
128 } 130 }
129 131
130 { 132 $0 ~ unsafe_gnu_url {
131 if (match($0, unsafe_gnu_url)) { 133 needs_rewriting = 1
132 url = substr($0, RSTART, RLENGTH)
133 printf "Use https: URL instead of '\''%s'\'' in commit message\n", url
134 status = 1
135 }
136 } 134 }
137 135
138 $0 ~ non_print { 136 $0 ~ non_print {
@@ -145,6 +143,21 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" '
145 print "Empty commit message" 143 print "Empty commit message"
146 status = 1 144 status = 1
147 } 145 }
146 if (status == 0 && needs_rewriting) {
147 for (i = 1; i <= NR; i++) {
148 line = input[i]
149 while (match(line, unsafe_gnu_url)) {
150 prefix = substr(line, 1, RSTART - 1)
151 suffix = substr(line, RSTART)
152 line = prefix "https:" substr(suffix, 5 + (suffix ~ /^http:/))
153 }
154 print line >file
155 }
156 if (close(file) != 0) {
157 print "Cannot rewrite: " file
158 status = 1
159 }
160 }
148 if (status != 0) { 161 if (status != 0) {
149 print "Commit aborted; please see the file 'CONTRIBUTE'" 162 print "Commit aborted; please see the file 'CONTRIBUTE'"
150 } 163 }