Skip to content
Snippets Groups Projects
Verified Commit 2b87e4ae authored by Karel Koci's avatar Karel Koci :metal:
Browse files

githooks: fix push reject when develop is directly based on master

The issue this fixes is that git reports same commit as being ancestor
of itself. It kind of makes sense but it breaks check if branch is based
on master or develop. In such case the common base between develop and
target branch and master and target branch is the same.

This changes the logic. Because git merge-base does effectively the
operation of 'less than or equal' we have to swap compare order and
negate the result. This way we get effectively the 'less than'
operation.
parent e9888b26
No related branches found
No related tags found
1 merge request!706githooks: fix push reject when develop is directly based on master
......@@ -41,13 +41,13 @@ while read -r local_ref local_sha1 remote_ref remote_sha1; do
push_develop="$local_sha1"
;;
hotfix/*)
if compare_ancestors "$local_sha1" master develop; then
if ! compare_ancestors "$local_sha1" develop master; then
echo "Reference has invalid ancestor, please base it on top of master: $local_ref" >&2
exit 1
fi
;;
feature/*|bugfix/*|refactor/*|hack/*)
if compare_ancestors "$local_sha1" develop master; then
if ! compare_ancestors "$local_sha1" master develop; then
echo "Reference has invalid ancestor, please base it on top of develop: $local_ref" >&2
exit 1
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment