1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Merge remote-tracking branch 'origin/master' into feature/android

This commit is contained in:
Po Lu 2023-04-24 08:49:30 +08:00
commit 85a9757b3c
6 changed files with 145 additions and 38 deletions

View file

@ -33,7 +33,7 @@
function get_commit_changes(commit_sha, changes, cmd, i, j, len, \
bits, filename) {
# Collect all the files touched in the specified commit.
cmd = ("git log -1 --name-status --format= " commit_sha)
cmd = ("git show --name-status --first-parent --format= " commit_sha)
while ((cmd | getline) > 0) {
for (i = 2; i <= NF; i++) {
len = split($i, bits, "/")
@ -59,15 +59,28 @@ function check_commit_msg_files(commit_sha, verbose, changes, good, \
if (verbose && ! msg)
msg = $0
# Find lines that reference files. We look at any line starting
# with "*" (possibly prefixed by "; ") where the file part starts
# with an alphanumeric character. The file part ends if we
# encounter any of the following characters: [ ( < { :
if (/^(; )?\*[ \t]+[[:alnum:]]/ && match($0, /[[:alnum:]][^[(<{:]*/)) {
# There might be multiple files listed on this line, separated
# by spaces (and possibly a comma). Iterate over each of them.
split(substr($0, RSTART, RLENGTH), filenames, ",?([[:blank:]]+|$)")
# Find file entries in the commit message. We look at any line
# starting with "*" (possibly prefixed by "; ") followed by a ":",
# possibly on a different line. If we encounter a blank line
# without seeing a ":", then we don't treat that as a file entry.
# Accumulate the contents of a (possible) file entry.
if (/^[ \t]*$/)
filenames_str = ""
else if (/^(; )?\*[ \t]+[[:alnum:]]/)
filenames_str = $0
else if (filenames_str)
filenames_str = (filenames_str $0)
# We have a file entry; analyze it.
if (filenames_str && /:/) {
# Delete the leading "*" and any trailing information.
sub(/^(; )?\*[ \t]+/, "", filenames_str)
sub(/[ \t]*[[(<:].*$/, "", filenames_str)
# There might be multiple files listed in this entry, separated
# by spaces (and possibly a comma). Iterate over each of them.
split(filenames_str, filenames, ",[ \t]+")
for (i in filenames) {
# Remove trailing slashes from any directory entries.
sub(/\/$/, "", filenames[i])
@ -83,6 +96,8 @@ function check_commit_msg_files(commit_sha, verbose, changes, good, \
good = 0
}
}
filenames_str = ""
}
}
close(cmd)

View file

@ -39,29 +39,32 @@ else
fi
# Standard input receives lines of the form:
# <local ref> SP <local name> SP <remote ref> SP <remote name> LF
# <local ref> SP <local sha> SP <remote ref> SP <remote sha> LF
$awk -v origin_name="$1" '
# If the local SHA is all zeroes, ignore it.
$2 ~ /^0{40}$/ {
next
}
$2 ~ /^[a-z0-9]{40}$/ {
# Check any lines with a valid local SHA and whose remote ref is
# master or an emacs-NN release branch. (We want to avoid checking
# feature or scratch branches here.)
$2 ~ /^[a-z0-9]{40}$/ && $3 ~ /^refs\/heads\/(master|emacs-[0-9]+)$/ {
newref = $2
# If the remote SHA is all zeroes, this is a new object to be
# pushed (likely a branch). Go backwards until we find a SHA on
# an origin branch.
# pushed (likely a branch)...
if ($4 ~ /^0{40}$/) {
back = 0
cmd = ("git branch -r -l '\''" origin_name "/*'\'' --contains " \
newref "~" back)
while ((cmd | getline) == 0) {
# Only look back at most 1000 commits, just in case...
if (back++ > 1000)
# ... Go backwards until we find a SHA on an origin branch.
# Stop trying after 1000 commits, just in case...
for (back = 0; back < 1000; back++) {
cmd = ("git branch -r -l '\''" origin_name "/*'\''" \
" --contains " newref "~" back)
rv = (cmd | getline)
close(cmd)
if (rv > 0)
break;
}
close(cmd)
cmd = ("git rev-parse " newref "~" back)
cmd | getline oldref
@ -78,6 +81,6 @@ $awk -v origin_name="$1" '
}
# Print every SHA after oldref, up to (and including) newref.
system("git rev-list --reverse " oldref ".." newref)
system("git rev-list --first-parent --reverse " oldref ".." newref)
}
' | $awk -v reason=pre-push -f .git/hooks/commit-msg-files.awk