fix(auth): preserve canonical clone base paths#142
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes HTTPS clone auth fallback to preserve the canonical stored Bitbucket base URL (including context path) when resolving stored credentials, so reconstructed clone URLs keep the correct base path.
Changes:
- Rebuilds HTTPS clone URLs using the canonical stored Bitbucket base URL when stored HTTP auth is used.
- Updates clone auth resolution to return the stored canonical Bitbucket URL (vs returning the input clone host).
- Adds regression coverage for host-matched but context-path-mismatched HTTPS fallback behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/cli/repo_clone.go | Adjusts stored-auth resolution and HTTPS fallback rebuild behavior to preserve canonical base URLs (context paths). |
| internal/cli/repo_clone_test.go | Updates expectations and adds a regression test for context-path mismatch handling in HTTPS fallback. |
| docs/quality/coverage.combined.scoped.out | Regenerated coverage artifact reflecting updated execution/coverage. |
| docs/quality/coverage.combined.raw.out | Regenerated coverage artifact reflecting updated execution/coverage. |
| docs/quality/coverage-report.json | Regenerated coverage report JSON reflecting updated patch/statement coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if hasStoredHTTPAuth && normalizeHTTPCloneBaseURL(httpCloneURL) != normalizeHTTPCloneBaseURL(resolvedHTTPCloneHost) { | ||
| httpCloneURL, err = buildBitbucketCloneURL(normalizeHTTPCloneBaseURL(resolvedHTTPCloneHost), repo.ProjectKey, repo.Slug) | ||
| if err != nil { |
There was a problem hiding this comment.
The comparison used to decide whether to rebuild the HTTPS clone URL is effectively always true: normalizeHTTPCloneBaseURL(httpCloneURL) includes the full /scm/<project>/<repo>.git path, while resolvedHTTPCloneHost is a base host URL (optionally with a context path). This means the code will rebuild the clone URL on every stored-auth HTTPS attempt, and it can also unintentionally override an explicit HTTP clone URL input even when no context-path correction is needed. Consider comparing base URLs of the same shape (e.g., extract scheme/host/+context from httpCloneURL before comparing), or compare cloneHost’s base against the canonical stored base instead of comparing the full clone URL to the base host URL.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 82.51% 82.53% +0.01%
==========================================
Files 78 78
Lines 15833 15833
==========================================
+ Hits 13065 13067 +2
+ Misses 1990 1989 -1
+ Partials 778 777 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Context
Validation