Compare commits

...

1 Commits

Author SHA1 Message Date
icecheng
2a26fb6795 fix(cli):fix for branch switching issues 2025-07-04 11:26:43 +08:00

View File

@ -2001,13 +2001,14 @@ devbox_init_command() {
if [ ! -d "$FREELEAPS_DIR" ]; then if [ ! -d "$FREELEAPS_DIR" ]; then
pushd "$WORKING_HOME" >/dev/null pushd "$WORKING_HOME" >/dev/null
log_info "Git cloning gitea.freeleaps.mathmast.com/products/freeleaps.git to $FREELEAPS_DIR" log_info "Git cloning gitea.freeleaps.mathmast.com/products/freeleaps.git to $FREELEAPS_DIR"
git clone --depth 5 $FRONTEND_GIT_URL git clone $FRONTEND_GIT_URL
# Checkout the specified branch # Checkout the specified branch
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
pushd "$FREELEAPS_DIR" >/dev/null pushd "$FREELEAPS_DIR" >/dev/null
log_info "Checking out branch: $GIT_BRANCH" log_info "Checking out branch: $GIT_BRANCH"
if ! git checkout $GIT_BRANCH; then if ! git checkout $GIT_BRANCH; then
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
fi fi
@ -2027,13 +2028,14 @@ devbox_init_command() {
gid=$(id -g) gid=$(id -g)
sudo chown -R ${uid}:${gid} "$WORKING_HOME" sudo chown -R ${uid}:${gid} "$WORKING_HOME"
git clone --depth 5 "$FRONTEND_GIT_URL" git clone "$FRONTEND_GIT_URL"
# Checkout the specified branch # Checkout the specified branch
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
pushd "$FREELEAPS_DIR" >/dev/null pushd "$FREELEAPS_DIR" >/dev/null
log_info "Checking out branch: $GIT_BRANCH" log_info "Checking out branch: $GIT_BRANCH"
if ! git checkout $GIT_BRANCH; then if ! git checkout $GIT_BRANCH; then
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
fi fi
@ -2054,6 +2056,7 @@ devbox_init_command() {
elif git checkout -b $GIT_BRANCH origin/$GIT_BRANCH 2>/dev/null; then elif git checkout -b $GIT_BRANCH origin/$GIT_BRANCH 2>/dev/null; then
log_info "Checked out remote branch: $GIT_BRANCH" log_info "Checked out remote branch: $GIT_BRANCH"
else else
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $FREELEAPS_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
fi fi
@ -2084,13 +2087,14 @@ devbox_init_command() {
if [ ! -d "$CUSTOM_DIR" ]; then if [ ! -d "$CUSTOM_DIR" ]; then
pushd "$WORKING_HOME" >/dev/null pushd "$WORKING_HOME" >/dev/null
log_info "Git cloning custom repository: $ECHO_USE_CUSTOM_REPOSITORY" log_info "Git cloning custom repository: $ECHO_USE_CUSTOM_REPOSITORY"
git clone --depth 5 "$USE_CUSTOM_REPOSITORY" git clone "$USE_CUSTOM_REPOSITORY"
# Checkout the specified branch # Checkout the specified branch
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
pushd "$CUSTOM_DIR" >/dev/null pushd "$CUSTOM_DIR" >/dev/null
log_info "Checking out branch: $GIT_BRANCH" log_info "Checking out branch: $GIT_BRANCH"
if ! git checkout $GIT_BRANCH; then if ! git checkout $GIT_BRANCH; then
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
fi fi
@ -2110,13 +2114,14 @@ devbox_init_command() {
gid=$(id -g) gid=$(id -g)
sudo chown -R ${uid}:${gid} "$WORKING_HOME" sudo chown -R ${uid}:${gid} "$WORKING_HOME"
git clone --depth 5 "$USE_CUSTOM_REPOSITORY" git clone "$USE_CUSTOM_REPOSITORY"
# Checkout the specified branch # Checkout the specified branch
if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then if [[ -n "$GIT_BRANCH" && "$GIT_BRANCH" != "main" ]]; then
pushd "$CUSTOM_DIR" >/dev/null pushd "$CUSTOM_DIR" >/dev/null
log_info "Checking out branch: $GIT_BRANCH" log_info "Checking out branch: $GIT_BRANCH"
if ! git checkout $GIT_BRANCH; then if ! git checkout $GIT_BRANCH; then
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
fi fi
@ -2130,6 +2135,7 @@ devbox_init_command() {
if [[ -n "$GIT_BRANCH" ]]; then if [[ -n "$GIT_BRANCH" ]]; then
log_info "Checking out branch: $GIT_BRANCH" log_info "Checking out branch: $GIT_BRANCH"
if ! git checkout $GIT_BRANCH; then if ! git checkout $GIT_BRANCH; then
log_warn "Please check if the $GIT_BRANCH branch exists locally in the path $CUSTOM_DIR. If it does not exist, you may attempt to manually pull the latest code."
log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch" log_warn "Failed to checkout branch $GIT_BRANCH, falling back to main branch"
git checkout main git checkout main
else else