Skip to content

Commit 46620c3

Browse files
authored
relax ghrepo validation (#4237)
* pin cspell version due to issue on last release * Relax detection of github host names during azd pipeline config. Folks can define an alias for a hostname to control the usage of different ssh keys. When this happens, the hostname will not be github.com, but it might be still pointing to github. This change relaxes the validation to allow any valid hostname. The command would fail later if the host is not accessible. * Relax detection of github host names during azd pipeline config. Folks can define an alias for a hostname to control the usage of different ssh keys. When this happens, the hostname will not be github.com, but it might be still pointing to github. This change relaxes the validation to allow any valid hostname. The command would fail later if the host is not accessible.
1 parent 1c0cb36 commit 46620c3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cli/azd/pkg/pipeline/github_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ func (p *GitHubScmProvider) configureGitRemote(
132132
}
133133

134134
// defines the structure of an ssl git remote
135-
var gitHubRemoteGitUrlRegex = regexp.MustCompile(`^git@github\.com:(.*?)(?:\.git)?$`)
135+
var gitHubRemoteGitUrlRegex = regexp.MustCompile(`^git@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}:(.*?)(?:\.git)?$`)
136136

137137
// defines the structure of an HTTPS git remote
138-
var gitHubRemoteHttpsUrlRegex = regexp.MustCompile(`^https://(?:www\.)?github\.com/(.*?)(?:\.git)?$`)
138+
var gitHubRemoteHttpsUrlRegex = regexp.MustCompile(`^https://(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/(.*?)(?:\.git)?$`)
139139

140140
// ErrRemoteHostIsNotGitHub the error used when a non GitHub remote is found
141141
var ErrRemoteHostIsNotGitHub = errors.New("not a github host")

cli/azd/pkg/pipeline/github_provider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Test_gitHub_provider_getRepoDetails(t *testing.T) {
4040
t.Run("error", func(t *testing.T) {
4141
provider := &GitHubScmProvider{}
4242
ctx := context.Background()
43-
details, e := provider.gitRepoDetails(ctx, "git@other.com:Azure/azure-dev.git")
43+
details, e := provider.gitRepoDetails(ctx, "gt@other.com:Azure/azure-dev.git")
4444
require.Error(t, e, ErrRemoteHostIsNotGitHub)
4545
require.EqualValues(t, (*gitRepositoryDetails)(nil), details)
4646
})

0 commit comments

Comments
 (0)