Skip to content

feat: check all git remotes for GitHub URL in ci migrate preflight#472

Merged
lukevmorris merged 1 commit intomainfrom
luke/jj-xwppzmmowoqs
Mar 28, 2026
Merged

feat: check all git remotes for GitHub URL in ci migrate preflight#472
lukevmorris merged 1 commit intomainfrom
luke/jj-xwppzmmowoqs

Conversation

@lukevmorris
Copy link
Copy Markdown
Member

@lukevmorris lukevmorris commented Mar 28, 2026

Previously, detectRepoFromGitRemote only checked the 'origin' remote. This is not a safe assumption, as a github remote could be saved under any arbitrary name, and some users even have multiple remotes configured. Now we iterate all configured remotes and pick the first one with a github.com URL. Also adds hostname validation to parseGitHubRepo to ensure non-GitHub remotes are correctly skipped.


Note

Low Risk
Low risk CLI behavior change limited to repository detection; main risk is selecting an unintended GitHub remote when multiple are configured.

Overview
Improves depot ci migrate repo detection by scanning all configured git remotes and selecting the first URL that parses as a github.com repo, instead of assuming an origin remote.

Tightens parseGitHubRepo to validate the hostname for both SSH and HTTPS remotes (skipping non-GitHub hosts), updates the related user-facing error messages, and adds unit tests covering common URL formats and non-GitHub cases.

Written by Cursor Bugbot for commit c34f1dd. This will update automatically on new commits. Configure here.

Previously, detectRepoFromGitRemote only checked the 'origin' remote.
Some customers have multiple remotes where origin does not point to
GitHub. Now we iterate all configured remotes and pick the first one
with a github.com URL. Also adds hostname validation to parseGitHubRepo
to ensure non-GitHub remotes are correctly skipped.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Remotes not prioritized, may detect wrong repo
    • Updated detectRepoFromGitRemote to resolve and validate origin first, then fall back to other remotes while skipping origin in the fallback loop.

Create PR

return repo
}
}
return ""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remotes not prioritized, may detect wrong repo

Low Severity

detectRepoFromGitRemote iterates remotes in .git/config order and picks the first GitHub match, without prioritizing origin. When a user has multiple GitHub remotes (e.g., upstream and origin), this may select the wrong repository if origin isn't listed first. In --yes mode, the result is used directly for ImportSecretsAndVars without displaying which repo was detected, so the user wouldn't notice. Checking origin first before falling back to other remotes would preserve the conventional expectation while still supporting non-origin setups.

Fix in Cursor Fix in Web

@lukevmorris lukevmorris merged commit fe51553 into main Mar 28, 2026
13 checks passed
@lukevmorris lukevmorris deleted the luke/jj-xwppzmmowoqs branch March 28, 2026 00:09
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