Skip to content

Clone GitHub owner/repo with your gh access, and add an existing checkout instead of refusing it - #1691

Merged
currentbits merged 2 commits into
mainfrom
coder/clone-from-url-and-publish-a-local-repo--5ad38d
Oct 19, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/clone-from-url-and-publish-a-local-repo--5ad38d

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes the clone half of #459. Typing owner/repo into Add project → Clone from URL now works, and private GitHub repos clone with the user's gh sign-in instead of failing on the missing git credential. The publish half already shipped as #456 in #1684.

Changes

  • The clone field now takes GitHub owner/repo shorthand as well as https and ssh URLs.
  • GitHub sources (shorthand or a github.com URL) clone via gh repo clone when gh auth token succeeds. Without gh they fall back to git clone, with shorthand expanded to https://github.com/owner/repo.git.
  • If the destination folder already holds a git checkout whose origin is the same host/owner/repo, it's added as the project instead of failing with "Folder is not empty". Any other non-empty folder is still refused.
  • The Clone into / Create new location now defaults to the folder containing the selected project instead of ~/.

Verification

  • electron/test/project-clone.test.js: 11/11. New cases cover the gh path, the git fallback for shorthand, and reuse plus host mismatch against a real git init checkout.
  • test/addProjectBrowse.test.tsx + addProjectCreate.test.tsx: 10/10, including the shorthand and the next-to-project default.
  • Full npm run test:electron (with the inherited CODER_GUARDRAILS_PATH unset): 4961/4961. tsc --noEmit is clean.
  • Not tested: a real gh repo clone against GitHub from the running app.

Notes for reviewers

  • The shorthand regex is the trust boundary. The owner must start with an alphanumeric, so nothing reaches gh or git as a flag, and ./.. repo names are rejected.
  • Reuse requires <target>/.git to exist, so a plain subfolder of some other repo can't match using its parent's origin. ssh host aliases (github-work:) won't match and get the old "not empty" error.
  • A signed-in gh with a revoked token fails with gh's own message; there's no retry via git.
  • Not included: resuming an interrupted clone.

claude-opus-5-5 via Claude Code

🤖 Generated with Claude Code

…ing checkout (#459)

The add-project clone field now takes owner/repo shorthand. GitHub sources
clone through `gh repo clone` when gh is signed in (private repos work),
otherwise plain git over https. A destination that already holds a clone of
the same repo is added instead of refused, and the clone/create location
defaults next to the selected project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T08:48:54.104705Z 343bf6f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 343bf6f110

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/projectClone.js
Comment on lines +84 to +86
const slug = slugFromRemoteUrl(url);
const host = remoteHostOf(url);
return slug && host ? `${host.host}/${slug}`.toLowerCase() : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the full remote path when matching checkouts

When cloning from a host that supports nested namespaces, slugFromRemoteUrl() retains only the final two path segments, so URLs such as https://gitlab.com/team-a/shared/repo and an existing origin at https://gitlab.com/team-b/shared/repo both produce gitlab.com/shared/repo. If the latter occupies the target folder, this equality silently calls addProject() for the wrong checkout instead of rejecting or cloning the requested repository; compare the complete normalized repository path rather than the shortened owner/repo slug.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit a1cdd5b into main Oct 19, 2026
4 of 6 checks passed
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