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

githooks: fix removal of branches

Removal of existing branch wasn't correctly handled. Merged branch
should be possible to remove but without this hook would complain that
it can't be removed because it is not based on top of master branch.
parent 848af2d4
Branches
Tags
1 merge request!697Turris OS 5.2 merge
......@@ -5,11 +5,6 @@ server_old="gitlab.labs.nic.cz"
zero_sha1="0000000000000000000000000000000000000000"
is_new_branch() {
local remote_sha1="$1"
[ "$remote_sha1" = "$zero_sha1" ]
}
compare_ancestors() {
local local_hash="$1"
[ "$local_hash" != "$zero_sha1" ] || return 0 # ignore removals
......@@ -32,6 +27,11 @@ push_master=
push_develop=
while read -r local_ref local_sha1 remote_ref remote_sha1; do
if [ "$local_sha1" = "$zero_sha1" ]; then
# Always allow removal of branches
continue
fi
remote_ref="${remote_ref#refs/heads/}"
case "$remote_ref" in
master)
......@@ -55,7 +55,7 @@ while read -r local_ref local_sha1 remote_ref remote_sha1; do
*)
# We terminate push only if this tries to create new branch of invalid
# name. This allows push to existing branches.
if is_new_branch "$remote_sha1"; then
if [ "$remote_sha1" = "$zero_sha1" ]; then
echo "Creation of new branch of this name is not allowed: $remote_ref" >&2
exit 1
fi
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment