Changeset f882048 in Klonkt for scripts


Ignore:
Timestamp:
06/29/2026 11:58:19 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
e954722
Parents:
aedc00d
Message:

fix(install): a re-run keeps the install's existing channel (no silent switch to stable)

A re-run without --branch fell back to the stable default, which would silently switch an
existing main install onto stable. Now a re-run detects the branch the install already tracks
and stays on it; only an explicit --branch / KLONKT_BRANCH overrides, and a fresh install still
defaults to stable. The chosen channel is thus a persistent property of the install, not a
per-command default.

  • scripts/install.sh — BRANCH_EXPLICIT flag (set by env KLONKT_BRANCH or --branch); on an existing .git checkout keep the current branch unless explicitly overridden; log the channel

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/install.sh

    raedc00d rf882048  
    2525# so a self-host auto-update (klonkt-update) never pulls work-in-progress. Use `--branch main`
    2626# for the bleeding-edge dev branch instead.
     27KLONKT_BRANCH_SET="${KLONKT_BRANCH:+1}"   # channel chosen via env? (empty = no, "1" = yes)
    2728KLONKT_BRANCH="${KLONKT_BRANCH:-stable}"
    2829KLONKT_DIR="${KLONKT_DIR:-/opt/klonkt}"
     
    3536NODE_FORCE="${NODE_FORCE:-}"        # set to 1 to (re)install system Node anyway
    3637PORT_EXPLICIT=0
     38BRANCH_EXPLICIT="${KLONKT_BRANCH_SET:-0}"   # 1 = operator chose the channel (env or --branch)
    3739
    3840while [ $# -gt 0 ]; do
     
    4042    --domain) KLONKT_DOMAIN="$2"; shift 2;;
    4143    --repo)   KLONKT_REPO="$2";   shift 2;;
    42     --branch) KLONKT_BRANCH="$2"; shift 2;;
     44    --branch) KLONKT_BRANCH="$2"; BRANCH_EXPLICIT=1; shift 2;;
    4345    --dir)    KLONKT_DIR="$2";    shift 2;;
    4446    --port)   KLONKT_PORT="$2"; PORT_EXPLICIT=1; shift 2;;
     
    141143if [ -d "$KLONKT_DIR/.git" ]; then
    142144  git -C "$KLONKT_DIR" remote set-url origin "$KLONKT_REPO"
     145  # Re-run on an EXISTING install: keep the channel this install already tracks — never
     146  # silently switch it to the stable default. Only an explicit --branch / KLONKT_BRANCH
     147  # overrides; a fresh install (else-branch) uses the stable default.
     148  if [ "$BRANCH_EXPLICIT" != "1" ]; then
     149    _cur=$(git -C "$KLONKT_DIR" rev-parse --abbrev-ref HEAD 2>/dev/null || true)
     150    [ -n "$_cur" ] && [ "$_cur" != "HEAD" ] && KLONKT_BRANCH="$_cur"
     151  fi
     152  log "Channel: $KLONKT_BRANCH"
    143153  git -C "$KLONKT_DIR" fetch --depth 1 origin "$KLONKT_BRANCH"
    144154  # Check out FETCH_HEAD AS the target branch — not `reset --hard origin/$KLONKT_BRANCH`
Note: See TracChangeset for help on using the changeset viewer.