Просмотр исходного кода

Add --branch support to install script

  The install script hardcoded origin/main, so beta testers told to
  install from a dev branch silently got the stable release instead.
  Add a --branch CLI option and interactive prompt (defaults to main).
  Fresh installs use git clone --branch, existing installs checkout
  and reset to the selected branch.
maziggy 6 месяцев назад
Родитель
Сommit
3a0b3f8035
2 измененных файлов с 20 добавлено и 3 удалено
  1. 1 0
      CHANGELOG.md
  2. 19 3
      install/install.sh

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **AMS Info Card & Custom Labels** ([#570](https://github.com/maziggy/bambuddy/pull/570)) — Hovering an AMS label (e.g. "AMS-A") on the Printers page now shows a popover with serial number, firmware version, and an editable friendly name. Custom labels are stored by AMS serial number so they persist when the unit is moved to a different printer. Slot numbers are now displayed inside each filament color circle with auto-inverted contrast for readability. Labels also appear in the Inventory page's location column. Contributed by @cadtoolbox.
 
 ### Improved
+- **Install Script: Branch Selection** — The native install script (`install.sh`) now supports a `--branch` option and an interactive branch prompt (defaults to `main`). Previously the script hardcoded `origin/main`, so beta testers told to install from a beta branch would silently get the stable release instead. Fresh installs use `git clone --branch`, existing installs checkout and reset to the selected branch. The install summary highlights non-main branches in yellow with a "(beta)" label.
 - **Print Queue Scheduler Diagnostics** ([#616](https://github.com/maziggy/bambuddy/issues/616)) — Added diagnostic logging to the print queue scheduler to help diagnose why queued prints aren't starting. After each queue check, the scheduler now logs a skip summary (how many items were skipped due to manual_start, scheduled_time, etc.) and for each busy printer, logs the exact state preventing it from being considered idle (connected status, printer state, plate_cleared flag). Previously the scheduler only logged "found N pending items" with no visibility into why items were skipped.
 
 ### Fixed

+ 19 - 3
install/install.sh

@@ -16,6 +16,7 @@
 #   --log-dir PATH     Log directory (default: INSTALL_PATH/logs)
 #   --debug            Enable debug mode
 #   --log-level LEVEL  Log level: DEBUG, INFO, WARNING, ERROR (default: INFO)
+#   --branch BRANCH    Git branch to install (default: main)
 #   --no-service       Skip systemd service setup (Linux only)
 #   --set-system-tz    Set system timezone to match (for unattended installs)
 #   --yes, -y          Non-interactive mode, accept defaults
@@ -55,6 +56,7 @@ NON_INTERACTIVE="false"
 OS_TYPE=""
 PKG_MANAGER=""
 PYTHON_CMD=""
+BRANCH=""
 SERVICE_USER="bambuddy"
 
 # -----------------------------------------------------------------------------
@@ -156,6 +158,7 @@ show_help() {
     echo "  --log-dir PATH     Log directory (default: INSTALL_PATH/logs)"
     echo "  --debug            Enable debug mode"
     echo "  --log-level LEVEL  Log level: DEBUG, INFO, WARNING, ERROR (default: INFO)"
+    echo "  --branch BRANCH    Git branch to install (default: main)"
     echo "  --no-service       Skip systemd service setup (Linux only)"
     echo "  --set-system-tz    Set system timezone to match (for unattended installs)"
     echo "  --yes, -y          Non-interactive mode, accept defaults"
@@ -338,17 +341,18 @@ download_bambuddy() {
         git config --global --add safe.directory "$INSTALL_PATH" 2>/dev/null || true
         cd "$INSTALL_PATH"
         git fetch origin
-        git reset --hard origin/main
+        git checkout "$BRANCH" 2>/dev/null || git checkout -b "$BRANCH" "origin/$BRANCH"
+        git reset --hard "origin/$BRANCH"
         # Ensure correct ownership after update
         sudo chown -R "$SERVICE_USER:$SERVICE_USER" "$INSTALL_PATH" 2>/dev/null || true
     else
         sudo mkdir -p "$INSTALL_PATH"
         sudo chown "$SERVICE_USER:$SERVICE_USER" "$INSTALL_PATH" 2>/dev/null || true
-        git clone https://github.com/maziggy/bambuddy.git "$INSTALL_PATH"
+        git clone --branch "$BRANCH" https://github.com/maziggy/bambuddy.git "$INSTALL_PATH"
         sudo chown -R "$SERVICE_USER:$SERVICE_USER" "$INSTALL_PATH" 2>/dev/null || true
     fi
 
-    log_success "BamBuddy downloaded to $INSTALL_PATH"
+    log_success "BamBuddy downloaded to $INSTALL_PATH (branch: $BRANCH)"
 }
 
 setup_virtualenv() {
@@ -656,6 +660,10 @@ parse_args() {
                 LOG_LEVEL="$2"
                 shift 2
                 ;;
+            --branch)
+                BRANCH="$2"
+                shift 2
+                ;;
             --no-service)
                 SKIP_SERVICE="true"
                 shift
@@ -688,6 +696,9 @@ gather_config() {
     # Installation path
     [[ -z "$INSTALL_PATH" ]] && prompt "Installation directory" "$DEFAULT_INSTALL_PATH" INSTALL_PATH
 
+    # Branch
+    [[ -z "$BRANCH" ]] && prompt "Git branch" "main" BRANCH
+
     # Port
     [[ -z "$PORT" ]] && prompt "Port to listen on" "$DEFAULT_PORT" PORT
 
@@ -749,6 +760,11 @@ gather_config() {
     echo -e "${BOLD}Installation Summary${NC}"
     echo -e "${CYAN}─────────────────────────────────────────${NC}"
     echo -e "  Install path:  ${GREEN}$INSTALL_PATH${NC}"
+    if [[ "$BRANCH" != "main" ]]; then
+        echo -e "  Branch:        ${YELLOW}$BRANCH${NC} (beta)"
+    else
+        echo -e "  Branch:        ${GREEN}$BRANCH${NC}"
+    fi
     echo -e "  Port:          ${GREEN}$PORT${NC}"
     echo -e "  Bind address:  ${GREEN}$BIND_ADDRESS${NC}"
     echo -e "  Timezone:      ${GREEN}$TIMEZONE${NC}"