1
0

change: disable branch selection

This commit is contained in:
2025-08-04 23:36:54 -05:00
parent f3496206eb
commit 96481590bc

View File

@@ -34,45 +34,45 @@ fi
# - New installs: git clone defaults to 'main', but you can switch to any branch # - New installs: git clone defaults to 'main', but you can switch to any branch
# - Existing installs: switch from current branch to a different one # - Existing installs: switch from current branch to a different one
# - Only runs in interactive terminals (skipped in automated/CI environments) # - Only runs in interactive terminals (skipped in automated/CI environments)
if [ -t 0 ] && [ -t 1 ] && [ -d ".git" ]; then # if [ -t 0 ] && [ -t 1 ] && [ -d ".git" ]; then
current_branch=$(git branch --show-current 2>/dev/null || echo "unknown") # current_branch=$(git branch --show-current 2>/dev/null || echo "unknown")
echo "Current branch: $current_branch" # echo "Current branch: $current_branch"
echo # echo
read -p "Switch to a different branch? (y/N): " -n 1 -r # read -p "Switch to a different branch? (y/N): " -n 1 -r
echo # echo
if [[ $REPLY =~ ^[Yy]$ ]]; then # if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Available branches:" # echo "Available branches:"
git branch -a --format="%(refname:short)" | grep -v "HEAD" | sed 's|^origin/||' | sort -u | nl -w2 -s'. ' # git branch -a --format="%(refname:short)" | grep -v "HEAD" | sed 's|^origin/||' | sort -u | nl -w2 -s'. '
branches=($(git branch -a --format="%(refname:short)" | grep -v "HEAD" | sed 's|^origin/||' | sort -u)) # branches=($(git branch -a --format="%(refname:short)" | grep -v "HEAD" | sed 's|^origin/||' | sort -u))
while true; do # while true; do
read -p "Enter branch number (1-${#branches[@]}): " branch_num # read -p "Enter branch number (1-${#branches[@]}): " branch_num
if [[ "$branch_num" =~ ^[0-9]+$ ]] && [ "$branch_num" -ge 1 ] && [ "$branch_num" -le "${#branches[@]}" ]; then # if [[ "$branch_num" =~ ^[0-9]+$ ]] && [ "$branch_num" -ge 1 ] && [ "$branch_num" -le "${#branches[@]}" ]; then
selected_branch="${branches[$((branch_num-1))]}" # selected_branch="${branches[$((branch_num-1))]}"
echo "Switching to branch: $selected_branch" # echo "Switching to branch: $selected_branch"
if git show-ref --verify --quiet "refs/heads/$selected_branch"; then # if git show-ref --verify --quiet "refs/heads/$selected_branch"; then
git checkout "$selected_branch" # git checkout "$selected_branch"
elif git show-ref --verify --quiet "refs/remotes/origin/$selected_branch"; then # elif git show-ref --verify --quiet "refs/remotes/origin/$selected_branch"; then
git checkout -b "$selected_branch" "origin/$selected_branch" # git checkout -b "$selected_branch" "origin/$selected_branch"
else # else
echo "Error: Branch $selected_branch not found" # echo "Error: Branch $selected_branch not found"
exit 1 # exit 1
fi # fi
git pull --quiet || true # git pull --quiet || true
echo "Switched to branch: $selected_branch" # echo "Switched to branch: $selected_branch"
break # break
else # else
echo "Invalid selection. Please enter a number between 1 and ${#branches[@]}" # echo "Invalid selection. Please enter a number between 1 and ${#branches[@]}"
fi # fi
done # done
fi # fi
fi # fi
# Hand off to setup # Hand off to setup
if [ -f "setup.sh" ]; then if [ -f "setup.sh" ]; then