From fcf7dc53547554507ed0fe76acd78d1ac0456d9e Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 16 Sep 2023 14:49:21 -0400 Subject: gitolite: Fix bug in default branch push trigger Since it is now allowed to remove the remote default branch, this script needs to handle cases where there are no branches following a push. In this case, the `git symbolic-ref` command will fail, and we return our standard warning for when HEAD is dangling. Signed-off-by: Malfurious --- gitolite/dotfiles/local/triggers/push | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gitolite/dotfiles/local/triggers/push') diff --git a/gitolite/dotfiles/local/triggers/push b/gitolite/dotfiles/local/triggers/push index 7a3cb56..2c5e060 100755 --- a/gitolite/dotfiles/local/triggers/push +++ b/gitolite/dotfiles/local/triggers/push @@ -7,8 +7,7 @@ head=$(git symbolic-ref HEAD) if ! [ -f "$head" ]; then set -- refs/heads/* - if [ "$#" -eq 1 ]; then - git symbolic-ref HEAD "$1" + if [ $# -eq 1 ] && git symbolic-ref HEAD "$1" >/dev/null 2>&1; then echo "NOTICE: Default branch set to $1" >&2 else echo "WARNING: The default branch is $head, but no such branch exists" >&2 -- cgit v1.2.3