Changeset 72f936a in Klonkt


Ignore:
Timestamp:
07/16/2026 12:20:51 PM (8 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
8878814
Parents:
df9da7d
git-author:
Robin <roboburr@…> (07/12/2026 11:37:06 PM)
git-committer:
Robin <roboburr@…> (07/16/2026 12:20:51 PM)
Message:

Fix: update check tracks the branch a checkout is on, not always main

BRANCH was hardcoded to main (unless KLONKT_BRANCH was set), so a self-hoster
who checked out the stable branch got the update panel comparing against
origin/main: main's commits shown as 'latest' plus a bogus 'behind' count.
A git checkout now defaults to its current branch (env override still wins,
then current branch, then main). The bare fleet is unaffected (it sets
KLONKT_BRANCH); Android already used stable.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/admin-updates.js

    rdf9da7d r72f936a  
    3131const HOME = process.env.HOME || '';
    3232const APP_DIR = process.cwd();
    33 const BRANCH = process.env.KLONKT_BRANCH || 'main';
    3433const GIT_DIR = process.env.KLONKT_GIT_DIR || path.join(HOME, 'git-repos/prutfolio.git');
    3534const UPDATE_SCRIPT = process.env.KLONKT_UPDATE_SCRIPT || path.join(HOME, 'bin/klonkt-self-update.sh');
     
    3938// a repo that actually exists, so it never logs "fatal: not a git repository".
    4039const IS_CHECKOUT = (() => { try { return fs.existsSync(path.join(APP_DIR, '.git')); } catch { return false; } })();
     40
     41// A checkout must track the branch it is ACTUALLY on: a self-hoster who checked out
     42// `stable` should be compared to origin/stable, not main — otherwise the update panel
     43// shows main's commits as "latest" and a bogus "behind" count (confusing for stable
     44// users). Env override wins (the bare fleet sets KLONKT_BRANCH); then the checkout's
     45// current branch; then main as a last resort.
     46const CHECKOUT_BRANCH = IS_CHECKOUT ? (() => {
     47  try {
     48    const b = execFileSync('git', ['-C', APP_DIR, 'rev-parse', '--abbrev-ref', 'HEAD'],
     49      { encoding: 'utf8', timeout: 8000, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
     50    return (b && b !== 'HEAD') ? b : null;
     51  } catch { return null; }
     52})() : null;
     53const BRANCH = process.env.KLONKT_BRANCH || CHECKOUT_BRANCH || 'main';
    4154const REMOTE_REF = IS_CHECKOUT ? `origin/${BRANCH}` : BRANCH; // what "latest" resolves to
    4255
Note: See TracChangeset for help on using the changeset viewer.