[Bug]: PR review guides fail to match pull requests on a GitHub fork when canonicalKey resolves to upstream
Summary
When a local T3 Code project is a GitHub fork whose repositoryIdentity resolves canonicalKey to the upstream parent repository (while origin.canonicalKey points to the user's fork), write_pull_request_guides (and the PR Guide tab) fails to match pull requests opened against the fork itself.
Reproduction
- Register a local checkout of a GitHub fork (
origin->https://github.com/<user>/<repo>.git, forked from<upstream>/<repo>). - Inspect the project via
t3_project_read:
(Note: even after renaming the local{ "repositoryIdentity": { "canonicalKey": "github.com/<upstream>/<repo>", "locator": { "source": "git-remote", "remoteName": "upstream", "remoteUrl": "https://github.com/<upstream>/<repo>.git" }, "origin": { "canonicalKey": "github.com/<user>/<repo>", "remoteUrl": "https://github.com/<user>/<repo>.git" } } }upstreamremote to another name and re-registering the project witht3_project_delete+t3_project_create,canonicalKeystill resolves to the upstream parent repo.) - Open a pull request targeting a branch inside the fork (
https://github.com/<user>/<repo>/pull/<N>). - Call
write_pull_request_guidesfor that PR URL (or open the PR Guide tab).
Actual Behavior
write_pull_request_guides fails with:
No project in this environment is a checkout of <user>/<repo>, so its pull requests cannot be read here. Add one with t3_project_create.
Expected Behavior
Because the registered project's repositoryIdentity.origin.canonicalKey already equals github.com/<user>/<repo>, T3 Code should match pull requests hosted on the fork (origin.canonicalKey) as well as canonicalKey when resolving a project checkout for PR review guides (and related PR reads).
Suggested Fix
When matching a PR's target repository against registered projects, check both project.repositoryIdentity.canonicalKey and project.repositoryIdentity.origin?.canonicalKey (preferring an exact match on origin.canonicalKey if the PR targets the fork directly).