Skip to content

feat(git): detect repo default branch instead of hardcoded dev fallback#618

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/land-detectdefaultbasebranch-base-branch-2026-06-03-13-55
Jun 3, 2026
Merged

feat(git): detect repo default branch instead of hardcoded dev fallback#618
NagyVikt merged 1 commit into
mainfrom
agent/claude/land-detectdefaultbasebranch-base-branch-2026-06-03-13-55

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

@NagyVikt NagyVikt commented Jun 3, 2026

Automated by gx branch finish (PR flow).

resolveBaseBranch / resolveFinishBaseBranch fell back to the hardcoded
DEFAULT_BASE_BRANCH ('dev') when no base was given or configured. On repos
whose real default is 'main' (or 'master'), the finish/PR flow then targeted a
non-existent 'dev', breaking PR creation and merges.

- Add detectDefaultBaseBranch(repoRoot): prefer the remote symbolic origin/HEAD,
  then the first existing branch among main/master/dev (local or origin), then
  fall back to DEFAULT_BASE_BRANCH. Export it.
- Wire it as the final fallback in resolveBaseBranch and resolveFinishBaseBranch.
- resolveFinishBaseBranch now honors per-branch branch.<source>.guardexBase
  (recorded at branch-start) before the repo-wide configured base.
- Add test/git-base-branch.test.js (precedence + fallback + explicit-base).

Detection uses read-only git probes (symbolic-ref, show-ref). Behavior changes
only on the no-config fallback path; explicit --base and configured base unchanged.
Verification: node --test 573 pass / 34 fail (baseline unchanged, +5 new passing);
openspec validate --specs + change --strict pass.
@NagyVikt NagyVikt merged commit a482841 into main Jun 3, 2026
1 of 2 checks passed
@NagyVikt NagyVikt deleted the agent/claude/land-detectdefaultbasebranch-base-branch-2026-06-03-13-55 branch June 3, 2026 12:08
NagyVikt added a commit that referenced this pull request Jun 3, 2026
…h, drop dead rawRun (plan phase 5) (#620)

Phase 5 of the gitguardex improvement plan (focused scope). Unblocked by #618.

- pr.js: remove the drifted local detectBaseBranch; resolve PR base via git's canonical
  detectDefaultBaseBranch (imported from ./git). Removed the redundant pr-module test
  (detector is covered by test/git-base-branch.test.js from #618).
- git/index.js: remove the dead `rawRun` import + `void rawRun;` scaffolding (deferred
  from Phase 1 A12 while the base-branch WIP was unlanded) and the stale JSDoc reference.

Deferred (with reasons): A3 sandbox-helper consolidation (3 of 8 helpers DRIFTED between
sandbox/index.js and cli/shared/sandbox.js -> needs drift reconciliation, not a partial
dedup); A7 launch.js registry-shape (inferred/not-verified defensive code); B5 finish
base-branch hoist (marginal perf, finish not a hot loop).

Verification: node --test 33 failures (baseline unchanged, zero new); the 3 pr-module
failures are pre-existing env failures (verified present on base). openspec validate pass.

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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.

1 participant