Skip to content

Fix detect_repo() picking upstream over origin in fork setups - #1

Merged
ashalliants merged 1 commit into
mainfrom
fix-repo-detection-origin-remote
Sep 7, 2026
Merged

ashalliants merged 1 commit into
mainfrom
fix-repo-detection-origin-remote

Conversation

@ashalliants

Copy link
Copy Markdown
Collaborator

Summary

  • detect_repo() in open_comments.py relied on gh repo view, which resolves the "current" repo from all configured git remotes. When a fork also has an upstream remote, gh can silently pick upstream instead of origin, causing the skill to operate on the wrong repo (wrong PR numbers, wrong comment/issue targets).
  • Fix: read the origin remote's URL directly (supports both SSH and HTTPS GitHub URLs) and fall back to gh repo view only if origin is missing or isn't a GitHub remote.

Test plan

  • Verified regex parses both git@github.com:owner/repo.git and https://github.com/owner/repo(.git) forms
  • Ran detect_repo() in this repo (which itself has a fork/upstream-style remote setup) and confirmed it resolves to origin correctly

gh repo view resolves the "current" repo from all configured remotes,
and when a fork also has an upstream remote pointing at the parent
repo, gh can silently pick upstream instead of origin -- causing the
skill to operate on the wrong repo entirely (wrong PR numbers, wrong
comment/issue targets). Read the origin remote's URL directly instead,
falling back to gh repo view only if origin is missing or not GitHub.
@ashalliants
ashalliants merged commit b85ce8c into main Sep 7, 2026
2 checks passed
@ashalliants
ashalliants deleted the fix-repo-detection-origin-remote branch September 7, 2026 10:08
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