Skip to content

fix(server): treat a repository's only non-origin remote as its primary remote - #22119

Open
only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:r9/g5-1
Open

only21mil wants to merge 2 commits into
pingdotgg:mainfrom
only21mil:r9/g5-1

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

Git status and the ref list report hasPrimaryRemote only when a remote is named origin. A repo cloned with git clone --origin github, or one where origin was renamed, has a remote but gets false. On an unpushed branch the Git action menu then has no Push or Create PR entries, and the quick action becomes "Publish repository", which creates a new hosted repository and adds an origin remote.

The server can already push in this setup. pushCurrentBranch picks the remote with resolvePushRemoteName, which falls back through resolvePrimaryRemoteName to the first remote when there is no origin. Only the flag the client reads still requires origin.

Repro on main: clone any repo with --origin github, create a branch, commit, and open the project. The Git control offers "Publish repository".

Change

In GitVcsDriverCore.ts:

  • The status cache runs git remote and reports a primary remote when any name is listed, instead of git remote get-url origin. The uncached path uses the existing listRemoteNames. The cache keeps its TTL and invalidation and is renamed from originExistsCache to primaryRemoteExistsCache.
  • The ref snapshot returns hasPrimaryRemote: remoteNames.length > 0 instead of remoteNames.includes("origin").

This is the same rule resolvePrimaryRemoteName uses for push: origin if it exists, otherwise the first remote git remote lists. With several remotes and no origin, push keeps its current choice (branch.<name>.pushRemote, then remote.pushDefault, then that first remote); this PR does not change it. A repo with no remotes still reports false, so "Publish repository" still shows there. No web, contract or schema change.

Scope and approval

Small focused fix of a contract mismatch: the server reports "no primary remote" for a repo it will push to. #15373 reported this setup (the only remote is named fork), and the maintainer triage on 2026-10-03 called it "a real lookup bug". It closed on 2026-10-18 with #20412, which fixed the PR lookup and fork detection for the only remote. This PR fixes the menu gate for the same setup.

#642 added the origin gate when push and PR creation needed origin. They no longer do, as above. The open fork-checkout report #17314 describes other callers that resolve a "primary remote"; this change makes the menu gate agree with the existing push rule (resolvePrimaryRemoteName) rather than adding a new rule.

Prior PRs: none attempted this change. #15403 (closed) changed only the PR lookup in GitManager.ts.

Verification

New test in apps/server/src/vcs/GitVcsDriverCore.test.ts, "treats a repository's only non-origin remote as its primary remote": a repo whose only remote is github must report hasOriginRemote from status details and hasPrimaryRemote from listRefs. Each assertion fails on main by itself (expected false to equal true) and passes on this branch.

The new test fails on main and passes on this branch

Other checks from apps/server on Linux x64, Node 24.22.0:

  • vp test run on GitVcsDriverCore.test.ts, GitManager.test.ts, GitWorkflowService.test.ts and SourceControlRepositoryService.test.ts: 4 files, 384 tests passed.
  • tsc-rs --noEmit: exit 0. vp fmt --check and vp lint on both files: clean (two existing lint warnings on lines this PR does not touch).

Browser check: a real Chromium at 1440x900 against a dev build (scripts/dev-runner.ts dev) with fresh state. First the build was main, then this branch. The project is a clone whose only remote is github (URL https://github.com/demo/demo-project.git, rewritten to a local bare repo), with one unpushed commit on feature/greeting.

The demo repo has one remote, github, and no origin; after Push, the branch tracks github/feature/greeting

Before, main: the quick action is "Publish repository" and the menu offers only Commit and Publish repository.

Main: Publish repository, menu has only Commit and Publish repository

After, this branch: the quick action is "Push & create PR" and the menu has Commit, Push and Create PR.

Branch: Push & create PR, menu has Commit, Push and Create PR

Clicking Push on the branch build pushed to the existing github remote and set the upstream to github/feature/greeting. It did not create an origin remote.

Branch: after Push, the control reads Pushed to github/feature/greeting

Not checked:

  • Create PR in the browser. The demo remote is not a real hosted repo, so I stopped after Push. fix(server): a branch on the only remote is not a fork when there is no origin #20412 fixed the PR head lookup on that path.
  • Default-branch detection still reads only refs/remotes/origin/HEAD, so in these repos no branch is marked default. That is a separate change.
  • Desktop and mobile clients. They read the same server flag; I did not run them.

Production fix, tests, PR description and images written with Claude Opus 5.5 in T3 Code Nightly.

🤖 Generated with Claude Opus 5.5 in T3 Code Nightly

only21mil and others added 2 commits October 19, 2026 22:26
…ry remote

Git status and the ref list reported hasPrimaryRemote only when a remote
was named origin. In a clone made with --origin <name>, or after renaming
origin, the Git menu hid Push and Create PR and offered "Publish
repository" instead, even though the push path already falls back to the
first remote through resolvePrimaryRemoteName.

Report a primary remote whenever any remote exists, which matches the
remote that push resolves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps STATUS_ORIGIN_EXISTS_CACHE_TTL so the change does not conflict
with open PRs that edit the neighboring constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 20, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 00a3976

Macroscope's review found this PR approvable — This small server-side fix aligns remote detection with the existing push fallback, allowing repositories with a non-origin remote to use the existing Push and Create PR actions instead of being treated as unpublished. Cache behavior and no-remote handling remain unchanged, and a focused regression test covers the affected case.

Notes:

  • Code review disabled. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b750c85-c572-43b4-a0b5-965bb53965d4
📥 Commits

Reviewing files that changed from the base of the PR and between a8dec0e and 00a3976.

📒 Files selected for processing: 2
  • apps/server/src/vcs/GitVcsDriverCore.test.ts
  • apps/server/src/vcs/GitVcsDriverCore.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

Git status and ref snapshots now treat any configured Git remote as a primary remote, rather than requiring a remote named origin. An integration test covers a repository with only a github remote.

Changes: Primary Remote Detection

Layer / File(s) Summary
Detect and report remote presence
apps/server/src/vcs/GitVcsDriverCore.ts, apps/server/src/vcs/GitVcsDriverCore.test.ts
The remote-existence cache, local status, and ref snapshots now recognize any configured remote. The test verifies this behavior with a github-only remote.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 00a39

The remote-detection change is consistent across status and ref snapshots, with no actionable merge-blocking risk established.

Architecture Summary

Architecture risk: 🔵 Low · up to 00a39

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriverCore.test.ts: Added an integration test creating a repository with only a github remote and asserting statusDetailsLocal reports hasOriginRemote and refreshed listRefs reports hasPrimaryRemote as true.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriverCore.ts: Replaced the origin URL lookup cache with a cache that runs git remote and reports true when the command succeeds and at least one remote name is present.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriverCore.ts: Status cache invalidation now targets the primary-remote existence cache instead of the origin-specific cache.
  • observed — Modified behavior in apps/server/src/vcs/GitVcsDriverCore.ts: Local status now determines remote presence from the primary-remote cache, or by listing remotes and checking whether the result is nonempty, rather than checking specifically for origin.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary fix: treating a repository's only non-origin remote as its primary remote.
Description check Passed The description includes all required sections. It explains the problem, change, scope and approval rationale, focused verification results, limitations, and the agent model and harness used.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant