fix(core): support canonical SSH URLs when extracting GitHub user/repo slug during nx release#31684
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit d9002e7
☁️ Nx Cloud last updated this comment at |
nx releasenx release
324464f to
cb600fb
Compare
cb600fb to
a0d2b35
Compare
|
@ekkolon I didn't want this one to just be auto-closed but at the same time you never promoted it out of draft - is closing the correct course of action here or will you have chance to finalize it? |
|
Hey @JamesHenry, thanks for the nudge. I plan to finalize this and move it out of draft shortly. Please keep it open. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
750c43a to
e1154f4
Compare
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Thanks! This also affects the GitHub hostname handling. I'll apply the same fallback there too. |
…slug during `nx release` Previously, the `nx release` command failed to create GitHub releases when the Git remote was configured using a canonical SSH-over-HTTPS URL (e.g. ssh://[email protected]:443/user/repo.git). The regex in `GithubRemoteReleaseClient.resolveRepoData()` failed to correctly extract the `user/repo` slug from these URLs. As a result, the release creation request was built with an incorrect slug (e.g. `443/user`) and the GitHub API call failed. This commit fixes the issue by extending the regex to handle fully qualified SSH URLs returned by `git remote get-url`, including cases where SSH is tunneled over HTTPS on port 443. It also adds unit tests to cover: - Successful parsing of canonical SSH URL formats - Graceful fallback on match failure - Malformed or non-GitHub remote URLs Closes #31682
4fb4cb6 to
d9002e7
Compare
…o slug during `nx release` (#31684) ## Current Behavior When running `nx release` with Git remotes configured as **canonical SSH URLs**, the repository slug is extracted incorrectly. Examples of affected remotes include: - `ssh://[email protected]:443/org/repo.git` - `ssh://[email protected]:2222/group/subgroup/repo.git` In these cases, the existing regex-based logic misinterprets the port number as part of the repository path (for example: `443/org`). This causes the release creation request to be built with an invalid repository slug and results in `404 Not Found` errors from the GitHub or GitLab APIs. ## Expected Behavior `nx release` should correctly extract the repository slug from all valid Git remote URL formats, regardless of whether the remote uses HTTPS, SCP-style SSH, or fully qualified SSH URLs with explicit ports. Valid examples should resolve to the correct slug: - `ssh://[email protected]:443/org/repo.git` => `org/repo` - `ssh://[email protected]:2222/group/subgroup/repo.git`=> `group/subgroup/repo` Users should not need to modify their Git remote configuration in order for `nx release` to work correctly. ## What’s Changed - Introduced a shared utility ([`extractRepoSlug`](https://github.com/nrwl/nx/pull/31684/changes#diff-799188c178b8a084e86dbe9063ec88a7c324212a8ef79729777f56e4bf7f455cR29-R60)) to consistently extract repository slugs from Git remote URLs. - Replaced provider-specific, regex-based parsing in: - `GithubRemoteReleaseClient` - `GitLabRemoteReleaseClient` - Added support for: - HTTPS remotes - SCP-style SSH remotes (`git@host:org/repo.git`) - Fully qualified SSH URLs with custom ports - Arbitrarily nested GitLab group and subgroup paths - Self-hosted GitHub and GitLab instances via hostname matching - Added comprehensive unit tests covering valid and invalid URL formats for both providers. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #31682 (cherry picked from commit 8255c28)
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
When running
nx releasewith Git remotes configured as canonical SSH URLs, the repository slug is extracted incorrectly.Examples of affected remotes include:
ssh://[email protected]:443/org/repo.gitssh://[email protected]:2222/group/subgroup/repo.gitIn these cases, the existing regex-based logic misinterprets the port number as part of the repository path (for example:
443/org). This causes the release creation request to be built with an invalid repository slug and results in404 Not Founderrors from the GitHub or GitLab APIs.Expected Behavior
nx releaseshould correctly extract the repository slug from all valid Git remote URL formats, regardless of whether the remote uses HTTPS, SCP-style SSH, or fully qualified SSH URLs with explicit ports.Valid examples should resolve to the correct slug:
ssh://[email protected]:443/org/repo.git=>org/repossh://[email protected]:2222/group/subgroup/repo.git=>group/subgroup/repoUsers should not need to modify their Git remote configuration in order for
nx releaseto work correctly.What’s Changed
extractRepoSlug) to consistently extract repository slugs from Git remote URLs.GithubRemoteReleaseClientGitLabRemoteReleaseClientgit@host:org/repo.git)Related Issue(s)
Fixes #31682