Commit 44b61be
refactor(git): consolidate PR/MR resolution into unified remote_ref module (#893)
* refactor(git): consolidate PR/MR resolution into unified remote_ref module
Replace duplicate pr_ref.rs (520 lines) and mr_ref.rs (715 lines) with a
trait-based architecture in remote_ref/. Both platforms now share:
- RemoteRefProvider trait defining the platform-agnostic interface
- RemoteRefInfo struct with platform-specific data in PlatformData enum
- Unified resolve_remote_ref() in switch.rs
Also:
- Add ref_path field to CreationMethod::ForkRef to avoid re-deriving
- Add -- separators to git fetch/worktree commands for security
- Update module docs to reflect current API
Net reduction: ~420 lines. Adding new platforms (e.g., Bitbucket) now
requires only implementing RemoteRefProvider.
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(gitlab): defer project URL fetching for ~1s perf improvement
GitLab fork MRs required 2 API calls (~500ms each) to fetch source and
target project URLs. These calls happened unconditionally, even when the
branch already tracked the MR (common case when re-switching).
Now:
- fetch_mr_info only fetches MR metadata (no project URL calls)
- fetch_gitlab_project_urls is called only after branch_tracks_ref fails
- For branches already configured, we skip ~1 second of API calls
Also fixes nested namespace display in source_ref output:
- extract_namespace_from_url now handles group/subgroup/repo correctly
- Example: git@gitlab.com:org/team/repo.git → org/team
Trade-off: Fork MR display now shows branch name only (not namespace:branch)
since fork_push_url isn't available until after the deferred fetch. The
full URL is still shown, and this only affects display, not functionality.
Co-Authored-By: Claude <noreply@anthropic.com>
* docs(gitlab): explain deferred URL fetching vs GitHub
Document why GitLab requires separate API calls for project URLs while
GitHub returns everything in one call. This explains the optimization
that defers URL fetching until after branch_tracks_ref check.
Co-Authored-By: Claude <noreply@anthropic.com>
* test(gitlab): add test for fetch_gitlab_project_urls validation
Cover the defensive check that rejects non-GitLab refs.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a567d5d commit 44b61be
11 files changed
+1260
-1597
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
0 commit comments