Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider username and password in repo urls #162

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tool/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

type AccountValidator struct{}

var repoDomainPattern = regexp.MustCompile("(?:https://|git@)([^/:]+)")
var repoDomainPattern = regexp.MustCompile("(?:https://(?:[^@:]+:[^@:]+@)?|git@)([^/:]+)")

func (v AccountValidator) Validate(repoURL string, account string) error {
domain, err := parseOutGitRepoDomain(repoURL)
Expand Down
3 changes: 3 additions & 0 deletions pkg/tool/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ func TestParseOutGitDomain(t *testing.T) {
}{
{"GitHub SSH", "[email protected]:foo/bar", "github.com", nil},
{"GitHub HTTPS", "https://github.com/foo/bar", "github.com", nil},
{"GitHub HTTPS with username/password", "https://foo:[email protected]/foo/bar", "github.com", nil},
{"Gitlab SSH", "[email protected]:foo/bar", "gitlab.com", nil},
{"Gitlab HTTPS", "https://gitlab.com/foo/bar", "gitlab.com", nil},
{"Gitlab HTTPS with username/password", "https://gitlab-ci-token:[email protected]/foo/bar", "gitlab.com", nil},
{"Bitbucket SSH", "[email protected]:foo/bar", "bitbucket.com", nil},
{"Bitbucket HTTPS", "https://bitbucket.com/foo/bar", "bitbucket.com", nil},
{"Bitbucket HTTPS with username/password", "https://user:[email protected]/foo/bar", "bitbucket.com", nil},
{"Invalid", "foo/bar", "", fmt.Errorf("Could not parse git repository domain for 'foo/bar'")},
}

Expand Down