aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2021-02-27 14:44:32 +0100
committerMichał Górny <mgorny@gentoo.org>2021-03-14 22:36:11 +0100
commit0213949276f9bd4ab33641f3988df225fc391b06 (patch)
tree8f1d00c409127db8f2780701ff8992057d2c1ce3
parentRemove a temporary file (diff)
downloadgithooks-0213949276f9bd4ab33641f3988df225fc391b06.tar.gz
githooks-0213949276f9bd4ab33641f3988df225fc391b06.tar.bz2
githooks-0213949276f9bd4ab33641f3988df225fc391b06.zip
local/update-06-copyright: Check only commits unreachable from any refsgithooks-20210314T213611Z
Closes: https://bugs.gentoo.org/772926 Signed-off-by: Ulrich Müller <ulm@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rwxr-xr-xlocal/tests/update-06-copyright.sh8
-rwxr-xr-xlocal/update-06-copyright21
2 files changed, 17 insertions, 12 deletions
diff --git a/local/tests/update-06-copyright.sh b/local/tests/update-06-copyright.sh
index 83b56c1..fcdeba5 100755
--- a/local/tests/update-06-copyright.sh
+++ b/local/tests/update-06-copyright.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# gentoo-infra: infra/githooks.git:tests/update-06-copyright.sh
# Tests for update-06-copyright hook
-# Copyright 2018 Michał Górny
+# Copyright 2018-2021 Michał Górny and others
# Distributed under the terms of the GNU General Public License v2 or later
. "${BASH_SOURCE%/*}"/lib.sh
@@ -377,6 +377,12 @@ git checkout --orphan test-branch -q
git commit --allow-empty -m "Commit without sign-off" -q
test_branch_failure test-branch "${FAIL_NO_SIGNOFF}"
+tbegin "New tag on independent branch"
+git checkout --orphan test-branch -q
+git commit --allow-empty -m "A commit" -q
+git tag test-tag
+test_tag_success test-tag
+
tbegin "Branch removal"
test_branch_removal
diff --git a/local/update-06-copyright b/local/update-06-copyright
index 4fe653d..01f5454 100755
--- a/local/update-06-copyright
+++ b/local/update-06-copyright
@@ -1,7 +1,7 @@
#!/bin/bash
# gentoo-infra: infra/githooks.git:update-06-copyright
# Verify that GCO sign-off is present in commit messages
-# Copyright 2018 Michał Górny
+# Copyright 2018-2021 Michał Górny and others
# Distributed under the terms of the GNU General Public License v2 or later
# Disable filename expansion
@@ -71,18 +71,17 @@ ret=0
zeros=0000000000000000000000000000000000000000
# branch removal
[[ ${newrev} == "${zeros}" ]] && exit 0
-# new branch; try to find a merge base with master
-if [[ ${oldrev} == "${zeros}" && ${refname} != refs/heads/master ]]; then
- mergebase=$(git merge-base refs/heads/master "${newrev}")
- [[ -n ${mergebase} ]] && oldrev=${mergebase}
- [[ -z ${mergebase} ]] && echo "WARNING: No common commits with master!"
-fi
rev_list_arg="${oldrev}..${newrev}"
-# new and no common commit? gotta check them all
-[[ ${oldrev} == "${zeros}" ]] && rev_list_arg="${newrev}"
+exec 10</dev/null
+# new branch; check all commits that are reachable from ${newrev}
+# but not reachable from any existing ref in refs/
+if [[ ${oldrev} == "${zeros}" ]]; then
+ rev_list_arg="${newrev}"
+ exec 10< <(git rev-parse --not --exclude="${refname}" --all)
+fi
while read -r commithash; do
- # verify that the commit message contains Signed-off-by
+ # verify that the commit message contains Signed-off-by
signoff=no
committer=$(git show -q --pretty=format:'%ce' "${commithash}")
@@ -165,7 +164,7 @@ while read -r commithash; do
echo " last found: ${realname}"
ret=1;;
esac
-done < <(git rev-list "${rev_list_arg}")
+done < <(git rev-list "${rev_list_arg}" --stdin <&10)
if [[ ${ret} == 1 ]]; then
echo