fix: support SSH remotes and reliable auth for private repos#123
Open
MalteHerrmann wants to merge 2 commits into
Open
fix: support SSH remotes and reliable auth for private repos#123MalteHerrmann wants to merge 2 commits into
MalteHerrmann wants to merge 2 commits into
Conversation
Parse owner/repo from HTTPS and SSH GitHub URLs so private repos cloned via SSH work in init, create-pr, and check-diff. Trim GITHUB_TOKEN and stop silently falling back to an unauthenticated client, which made private repositories return misleading 404s. Propagate non-404 errors from the branch existence check instead of reporting pushed branches as missing. Fixes #122, fixes #121 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issues with private repositories (especially those authenticated via SSH) that caused
clu create-prandclu check-diffto fail. Addresses #122 and the linked #121.Three root causes were identified and fixed:
get_origin()(used byclu init) andget_git_info()(used bycreate-pr/check-diff) only matchedhttps://github.com/.... The SSH formgit@github.com:owner/repo.gitnever matched (colon vs. slash). Addedparse_github_owner_repo()that handles HTTPS, SCP-style SSH,ssh://, and bare URLs (with optional.git/trailing slash), and normalizes origins to canonical HTTPS.get_github_client()usedunwrap_or_default(), silently degrading to an unauthenticated client. GitHub returns404 Not Found(not 403) for private resources without valid auth — the exact error in Error checking diff on PR #121. The client now surfaces build errors instead of degrading, and theGITHUB_TOKENis trimmed to avoidAuthorizationheader corruption from trailing whitespace/newlines (e.g.$(op read ...)).branch_exists_on_remote. Previously used.is_ok(), so auth/network failures looked identical to "branch missing" — the Failed to create PR #122 symptom where a pushed branch keeps being reported as missing. It now returnsResult<bool>, treating only genuine 404s as "absent" and propagating other errors with a helpful message.Changes
src/utils/git.rs: newparse_github_owner_repo()+ rewiredget_origin()/get_git_info(); added unit tests.src/utils/github.rs: token trimming, no silent unauthenticated fallback,branch_exists_on_remote()returnsResult<bool>.src/cli/create_pr.rs: updated call sites for the new signature.Test plan
cargo buildpassescargo test --libpasses (new URL-parsing tests included; only the pre-existingANTHROPIC_API_KEY-dependent test fails, unrelated to this change)GITHUB_TOKEN) thatcreate-prdetects a pushed branch andcheck-diffworks. If Error checking diff on PR #121 persists, confirm the token's scope grants access to that private repo.Made with Cursor