aboutsummaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2019-12-15 12:47:25 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2019-12-15 22:22:39 -0800
commit2b4f4e585abe23731bdec26d61b21b072d7df2a3 (patch)
treef09e3696a498bde41afd30fc0a42f7565db20efc /local
parentlocal/update-06-copyright: detect if a new ref has no common commits to master (diff)
downloadgithooks-2b4f4e585abe23731bdec26d61b21b072d7df2a3.tar.gz
githooks-2b4f4e585abe23731bdec26d61b21b072d7df2a3.tar.bz2
githooks-2b4f4e585abe23731bdec26d61b21b072d7df2a3.zip
local/update*: ensure correct handling for add/del branch/tags
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> (cherry picked from commit 63f9eb4e442d4a03fcdfffcddc8cf6fbdc6e6d15)
Diffstat (limited to 'local')
-rwxr-xr-xlocal/update-03-filename11
-rwxr-xr-xlocal/update-04-utf811
-rwxr-xr-xlocal/update-05-manifest11
3 files changed, 33 insertions, 0 deletions
diff --git a/local/update-03-filename b/local/update-03-filename
index da2c8ff..a1d8a03 100755
--- a/local/update-03-filename
+++ b/local/update-03-filename
@@ -11,6 +11,17 @@ newrev=$3
# skip non-master commits
[[ ${refname} == refs/heads/master ]] || exit 0
+# special cases
+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
+
# Filenames must contain only the characters [A-Za-z0-9._+-] and must
# not begin with a dot, a hyphen, or a plus sign.
# https://devmanual.gentoo.org/general-concepts/tree/#what-belongs-in-the-tree%3F
diff --git a/local/update-04-utf8 b/local/update-04-utf8
index 8195931..3d2f9f3 100755
--- a/local/update-04-utf8
+++ b/local/update-04-utf8
@@ -10,6 +10,17 @@ newrev=$3
export LC_MESSAGES=C
+# special cases
+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
+
ret=0
while read commithash; do
# verify that the commit object (including author, committer, commit
diff --git a/local/update-05-manifest b/local/update-05-manifest
index 42afd2a..236c78f 100755
--- a/local/update-05-manifest
+++ b/local/update-05-manifest
@@ -13,6 +13,17 @@ export LC_MESSAGES=C
# enforce only on master branch
[[ ${refname} == refs/heads/master ]] || exit 0
+# special cases
+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
+
ret=0
while read commithash; do
# check for any Manifest changes