Skip to content

polish(selfhost): sharpen selfhost-update.sh error precision #4156

Description

@JSONbored

Summary

Follow-up to #1660 / #4151 (merged): the Gittensory Orb review on #4151 flagged two
non-blocking precision nits in the new scripts/selfhost-update.sh that are worth
fixing before they confuse an operator in the field.

Details

  1. The git merge --ff-only failure path prints the same "local history has diverged"
    message regardless of the actual cause. If SELFHOST_UPDATE_BRANCH/
    SELFHOST_UPDATE_REMOTE is mistyped (or points at a branch the remote genuinely
    doesn't have), git merge --ff-only <bad-ref> fails the same way as a real
    divergence, and the operator gets told their history has diverged when the real
    problem is a bad ref. Add a git rev-parse --verify check right after the fetch so
    a missing ref gets its own distinct, actionable error.
  2. current_branch="$(git rev-parse --abbrev-ref HEAD)" returns the literal string
    HEAD in a detached-HEAD checkout, so the existing branch-mismatch error reads
    "currently on 'HEAD', expected 'main'" and suggests a nonsensical
    SELFHOST_UPDATE_BRANCH=HEAD override. Give detached HEAD its own message.

A related doc/test correction: test/unit/docs-selfhost-git-deploy-hygiene.test.ts's
comment on the tracked-file-shadowing test overstated the risk of a tracked file
matching the new .gitignore backup patterns (.gitignore does not untrack an
already-tracked file, verified empirically). Correct the comment to describe the real
risk: a new file matching the pattern would be silently excluded from git status
and git add -A, not that an existing tracked file would be dropped.

Acceptance criteria

  • scripts/selfhost-update.sh gives a distinct error for a missing/invalid
    $REMOTE/$BRANCH ref, separate from the non-fast-forward-divergence error.
  • scripts/selfhost-update.sh gives a distinct error for a detached-HEAD checkout.
  • The inaccurate .gitignore semantics claim in the test comment is corrected.
  • New test coverage for both new error paths.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions