mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
When examining merge commits in our Git hooks, only check the first parent
This does two things: 1. We can properly validate log entries in merge commits. 2. We don't check commits that were merged in from other branches. * build-aux/git-hooks/commit-msg-files.awk (get_commit_changes): Get the changes compared to the first parent. * build-aux/git-hooks/pre-push: Only get the first parent of merge commits when returning the rev-list, and only check "master" or "emacs-NN" branches.
This commit is contained in:
parent
e26dcc0e14
commit
3ce462c8fd
2 changed files with 7 additions and 4 deletions
|
|
@ -33,7 +33,7 @@
|
||||||
function get_commit_changes(commit_sha, changes, cmd, i, j, len, \
|
function get_commit_changes(commit_sha, changes, cmd, i, j, len, \
|
||||||
bits, filename) {
|
bits, filename) {
|
||||||
# Collect all the files touched in the specified commit.
|
# 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) {
|
while ((cmd | getline) > 0) {
|
||||||
for (i = 2; i <= NF; i++) {
|
for (i = 2; i <= NF; i++) {
|
||||||
len = split($i, bits, "/")
|
len = split($i, bits, "/")
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,17 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Standard input receives lines of the form:
|
# 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" '
|
$awk -v origin_name="$1" '
|
||||||
# If the local SHA is all zeroes, ignore it.
|
# If the local SHA is all zeroes, ignore it.
|
||||||
$2 ~ /^0{40}$/ {
|
$2 ~ /^0{40}$/ {
|
||||||
next
|
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
|
newref = $2
|
||||||
# If the remote SHA is all zeroes, this is a new object to be
|
# If the remote SHA is all zeroes, this is a new object to be
|
||||||
# pushed (likely a branch)...
|
# pushed (likely a branch)...
|
||||||
|
|
@ -78,6 +81,6 @@ $awk -v origin_name="$1" '
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print every SHA after oldref, up to (and including) newref.
|
# 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
|
' | $awk -v reason=pre-push -f .git/hooks/commit-msg-files.awk
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue