Further enhancments to load-branch. Better output and branch choices.

This commit is contained in:
2025-10-15 06:06:05 -07:00
parent d916637798
commit 13bc98d7ef

View File

@@ -896,19 +896,33 @@
function load-branch { function load-branch {
rcvr="$1" # branch which we want to modify rcvr="$1" # branch which we want to modify
base="$2" # branch with the changes we want base="$2" # branch with the changes we want
if [[ "$rcvr" == main ]]; then if [[ "$rcvr" == "main" ]]; then
echo "Are you nuts, fool!? Not main! Do it manually!" echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***"
exit 1 exit 1
fi fi
if [[ -z "$base" ]]; then if [[ -z "$base" ]]; then
base="dev" if [[ "$rcvr" == "prod" ]]; then
base="stage"
elif [[ "$rcvr" == "stage" ]]; then
base="dev"
else
echo "* Unsure which branch to use for '$rcvr'. Please specify."
exit 1
fi
echo "* Base not specified, using '$base' for '$rcvr'."
fi fi
echo "* Ensuring we are on base branch '$base'."
git switch "$base" git switch "$base"
echo "* Changing pointer for '$rcvr' to '$base'."
git branch -f "$rcvr" "$base" git branch -f "$rcvr" "$base"
#echo "* Switching to branch '$rcvr'."
#git switch "$rcvr" #git switch "$rcvr"
echo "* Forcing push on branch '$rcvr'."
git push --force --set-upstream origin "$rcvr" git push --force --set-upstream origin "$rcvr"
#echo "* Switching back to '$base'."
#git switch "$base" #git switch "$base"
git branch echo "* Done! Displaying list of remote branches."
git ls-remote --heads | sort
} }
alias load-prod="load-branch prod" alias load-prod="load-branch prod"
alias load-stage="load-branch stage" alias load-stage="load-branch stage"