summaryrefslogtreecommitdiff
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 12:47:25 -0800
commit63f9eb4e442d4a03fcdfffcddc8cf6fbdc6e6d15 (patch)
tree9151cb237ac0fb6c6500d19bf4a05438006b329c
parentlocal/update-06-copyright: detect if a new ref has no common commits to master (diff)
downloadgithooks-63f9eb4e442d4a03fcdfffcddc8cf6fbdc6e6d15.tar.gz
githooks-63f9eb4e442d4a03fcdfffcddc8cf6fbdc6e6d15.tar.bz2
githooks-63f9eb4e442d4a03fcdfffcddc8cf6fbdc6e6d15.zip
local/update*: ensure correct handling for add/del branch/tagsgithooks-20191215T204800Z
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-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 5558029..6871175 100755
--- a/local/update-03-filename
+++ b/local/update-03-filename
@@ -12,6 +12,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 32bd738..0365dec 100755
--- a/local/update-04-utf8
+++ b/local/update-04-utf8
@@ -11,6 +11,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 2dda5c7..4649fc3 100755
--- a/local/update-05-manifest
+++ b/local/update-05-manifest
@@ -14,6 +14,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