Support custom SSH usernames for install sources#178
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the SSH URL parsing and normalization logic to support custom SSH usernames (e.g., for GitHub Enterprise Data Residency environments using *.ghe.com domains) instead of hardcoding git@. This includes updating regex patterns, normalization logic, and parsing functions, along with adding corresponding unit tests. Feedback on the changes highlights an issue in gitHubOwnerRepo(), where the host check only looks for the substring "github". This will fail for GHE Data Residency domains (*.ghe.com), so the check should be updated to also recognize ghe.com.
| host := strings.ToLower(strings.TrimSpace(sshMatches[2])) | ||
| if !strings.Contains(host, "github") { | ||
| return "", "" | ||
| } |
There was a problem hiding this comment.
For GitHub Enterprise Data Residency environments (which use *.ghe.com domains), the host will not contain the substring "github". As a result, gitHubOwnerRepo() will fail to extract the owner and repository name, returning empty strings. This will break any GitHub-specific integrations or metadata extraction for these sources.
Please update the host check to also recognize ghe.com domains. Note that you should also apply a similar update to the HTTPS parsing logic below (around line 559), although it is outside the current diff hunk.
| host := strings.ToLower(strings.TrimSpace(sshMatches[2])) | |
| if !strings.Contains(host, "github") { | |
| return "", "" | |
| } | |
| host := strings.ToLower(strings.TrimSpace(sshMatches[2])) | |
| if !strings.Contains(host, "github") && !strings.Contains(host, "ghe.com") { | |
| return "", "" | |
| } |
|
Checked this path locally because it touches the install source parser and the PR is currently behind main. I did not find a blocker. What I verified:
Local validation on
The only operational note I see is that the branch is behind main, but the install-package changes looked clean in the merge check above. |
Implemented parsing for SSH source URLs that use a custom username, such as GitHub Enterprise Data Residency remotes like
acme@acme.ghe.com:Org/repo.git. The parser now preserves the SSH username in the clone URL, skips GitHub shorthand expansion for these inputs, and normalizes custom-username SSH URLs for conflict detection.This fixes installs from GHE Data Residency environments where the SSH username is not
git.Fixes #176
Tests:
go test ./internal/install -run 'TestParseSource_GitSSH|TestParseSource_GitHubEnterprise|TestParseSource_GitHubEnterprise_TrackName|TestNormalizeCloneURL'./scripts/test.sh --unit --quiet./scripts/test.sh --quiet