Do not reject https://gnu.org in commit messages
* build-aux/git-hooks/commit-msg: Do not reject commit messages containing http: or ftp: URLs to gnu.org or fsf.org. Instead, rewrite the messages to use https: URLs.
This commit is contained in:
parent
fb4200a875
commit
a0b7b301dd
1 changed files with 20 additions and 7 deletions
|
@ -44,7 +44,7 @@ if test "$at_sign" != @; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the log entry.
|
# 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 {
|
BEGIN {
|
||||||
# These regular expressions assume traditional Unix unibyte behavior.
|
# These regular expressions assume traditional Unix unibyte behavior.
|
||||||
# They are needed for old or broken versions of awk, e.g.,
|
# 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" '
|
||||||
unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org"
|
unsafe_gnu_url = "(http|ftp)://([" c_lower ".]*\\.)?(gnu|fsf)\\.org"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ input[NR] = $0 }
|
||||||
|
|
||||||
/^#/ {
|
/^#/ {
|
||||||
# Ignore every line after a scissors line.
|
# Ignore every line after a scissors line.
|
||||||
if (/^# *---* *(>[8%]|[8%]<) *---* *$/) { exit }
|
if (/^# *---* *(>[8%]|[8%]<) *---* *$/) { exit }
|
||||||
|
@ -127,12 +129,8 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" '
|
||||||
status = 1
|
status = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
$0 ~ unsafe_gnu_url {
|
||||||
if (match($0, unsafe_gnu_url)) {
|
needs_rewriting = 1
|
||||||
url = substr($0, RSTART, RLENGTH)
|
|
||||||
printf "Use https: URL instead of '\''%s'\'' in commit message\n", url
|
|
||||||
status = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$0 ~ non_print {
|
$0 ~ non_print {
|
||||||
|
@ -145,6 +143,21 @@ exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" '
|
||||||
print "Empty commit message"
|
print "Empty commit message"
|
||||||
status = 1
|
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) {
|
if (status != 0) {
|
||||||
print "Commit aborted; please see the file 'CONTRIBUTE'"
|
print "Commit aborted; please see the file 'CONTRIBUTE'"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue