Skip to content

feat(sync): add --branch flag to sync from a specific branch#29

Merged
pike00 merged 1 commit into
mainfrom
feat/sync-branch-flag
Jun 16, 2026
Merged

feat(sync): add --branch flag to sync from a specific branch#29
pike00 merged 1 commit into
mainfrom
feat/sync-branch-flag

Conversation

@pike00

@pike00 pike00 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

What

Adds stag sync --branch <name> to sync the config from a specific branch instead of the repository's default branch. Handy for testing standards changes on a branch before merging them to the default branch.

Why

runSync currently always resolves the branch via GetDefaultBranch, with no way to override it. The GitHub client already accepts a ?ref=<branch> argument on FetchFile/ListDirectory/FileExists - this just wires a flag through to it.

How

  • New --branch flag on stag sync, plumbed through a small resolveBranch helper (explicit override, else the repo default).
  • An explicit --branch always fetches. The cache is keyed by owner/repo, not by branch, so the cache-freshness short-circuit is skipped when --branch is set - otherwise a fresh default-branch cache would silently serve the wrong content for a branch request.
  • --branch is rejected for multi-source configurations, since a single branch can't meaningfully apply across multiple source repos.
  • Unit test covering the override path; README CLI reference and CHANGELOG updated.

Lets `stag sync --branch <name>` pull config from a non-default branch,
useful for testing standards changes before merging. The branch feeds the
existing ?ref= GitHub plumbing via a new resolveBranch helper.

An explicit --branch always fetches: the cache is keyed by owner/repo (not
branch), so the freshness short-circuit is skipped to avoid serving
default-branch content. --branch is rejected for multi-source configs,
which target multiple repos.
@pike00 pike00 requested a review from HartBrook June 15, 2026 16:04

@HartBrook HartBrook left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it

@pike00 pike00 merged commit db2d450 into main Jun 16, 2026
4 checks passed
@pike00 pike00 deleted the feat/sync-branch-flag branch June 16, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants