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