#!/bin/bash # # kbgit-set-main # John Simpson 2022-01-08 # # Set the primary branch of a Keybase git repo # # 2023-06-26 jms1 - renamed to 'kbgit-set-main' # # 2024-07-27 jms1 - detect team/repo name if not supplied set -e ############################################################################### # # usage function usage { MSG="${*:-}" cat <&2 cd "$RDIR" ######################################## # Show the current HEAD file ( set -x ; cat HEAD ) ############################################################################### # # If we're changing it, do the deed if [[ -n "$BRANCH" ]] then ######################################## # Does the branch exist in the repo? BRF="$( git branch -a | grep " $BRANCH\$" || true )" if [[ -n "$BRF" ]] then ( set -x ; echo "ref: refs/heads/$BRANCH" > HEAD ) ( set -x ; cat HEAD ) else echo "ERROR: branch '$BRANCH' does not exist in this repo" exit 1 fi fi