aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2021-03-24 11:04:35 +0100
committerMichał Górny <mgorny@gentoo.org>2021-03-24 11:33:27 +0100
commitba53933add13608c6fa01f3146cd316a2f20b8be (patch)
treefc4623156a602b718518f751f8af88bc71791541 /local
parentlocal/update-06-copyright: Check only commits unreachable from any refs (diff)
downloadgithooks-ba53933add13608c6fa01f3146cd316a2f20b8be.tar.gz
githooks-ba53933add13608c6fa01f3146cd316a2f20b8be.tar.bz2
githooks-ba53933add13608c6fa01f3146cd316a2f20b8be.zip
local/update-*: Check for unreachable commits also in other hooksgithooks-20210324T103327Z
To this end, sync update-04-utf8 from update-06-copyright. update-03-filename and update-05-manifest check commits only in master, so we need not consider branch creation. Signed-off-by: Ulrich Müller <ulm@gentoo.org> Closes: https://bugs.gentoo.org/772926 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'local')
-rwxr-xr-xlocal/update-03-filename9
-rwxr-xr-xlocal/update-04-utf816
-rwxr-xr-xlocal/update-05-manifest9
3 files changed, 13 insertions, 21 deletions
diff --git a/local/update-03-filename b/local/update-03-filename
index 64e014b..63ef270 100755
--- a/local/update-03-filename
+++ b/local/update-03-filename
@@ -1,6 +1,6 @@
#!/bin/bash
# gentoo-infra: infra/githooks.git:update-03-filename
-# Copyright 2015-2017 Gentoo Foundation
+# Copyright 2015-2021 Ulrich Müller and others
# Distributed under the terms of the GNU General Public License v2 or later
# Author: Ulrich Müller <ulm@gentoo.org>
@@ -16,12 +16,7 @@ newrev=$3
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
+# no need to check for new branch because we skip non-master commits above
# Filenames must contain only the characters [A-Za-z0-9._+-] and must
# not begin with a dot, a hyphen, or a plus sign.
diff --git a/local/update-04-utf8 b/local/update-04-utf8
index 0ad8b5b..1b18834 100755
--- a/local/update-04-utf8
+++ b/local/update-04-utf8
@@ -1,6 +1,6 @@
#!/bin/bash
# gentoo-infra: infra/githooks.git:update-04-utf8
-# Copyright 2017 Gentoo Foundation
+# Copyright 2017-2021 Michał Górny and others
# Distributed under the terms of the GNU General Public License v2 or later
# Author: Michał Górny <mgorny@gentoo.org>
@@ -15,11 +15,13 @@ export LC_MESSAGES=C
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!"
+rev_list_arg="${oldrev}..${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
ret=0
@@ -31,6 +33,6 @@ while read commithash; do
echo "Commit ${commithash} contains invalid UTF-8 in the commit metadata"
ret=1
fi
-done < <(git rev-list "${oldrev}..${newrev}")
+done < <(git rev-list "${rev_list_arg}" --stdin <&10)
exit ${ret}
diff --git a/local/update-05-manifest b/local/update-05-manifest
index 8ae0bc4..94fc593 100755
--- a/local/update-05-manifest
+++ b/local/update-05-manifest
@@ -1,6 +1,6 @@
#!/bin/bash
# gentoo-infra: infra/githooks.git:update-05-manifest
-# Copyright 2017 Gentoo Foundation
+# Copyright 2017-2021 Michał Górny and others
# Distributed under the terms of the GNU General Public License v2 or later
# Author: Michał Górny <mgorny@gentoo.org>
@@ -18,12 +18,7 @@ export LC_MESSAGES=C
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
+# no need to check for new branch because we skip non-master commits above
ret=0
while read commithash; do