aboutsummaryrefslogtreecommitdiff
path: root/local/triggers/POST_GIT/fix_default_branch.sh
blob: ee5173a2e71ca866a95496272d5af50b38c6927d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

cd /srv/git/repositories/"$2".git
branch_count=$(git branch | wc -l)

[ "${branch_count}" -eq 1 ] || exit
git for-each-ref --format='%(refname:short)' refs/heads/ | sort -d | while read -r branch; do
    case "${branch}" in
        main|master) : ;;
        *) continue ;;
    esac

    git symbolic-ref HEAD refs/heads/"${branch}"
done