fix: allow dots in a repository path's "user" section (#106)

GitLab uses "first.last" naming for personal Groups.
This fixes the ability to reference personal GitLab
projects with jb.
This commit is contained in:
Benoit Gagnon 2020-05-19 16:55:33 -04:00 committed by GitHub
parent 447344d5a0
commit 251792fbb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -106,8 +106,8 @@ const (
gitSSHExp = `ssh://git@(?P<host>.+)/(?P<user>.+)/(?P<repo>.+).git` gitSSHExp = `ssh://git@(?P<host>.+)/(?P<user>.+)/(?P<repo>.+).git`
gitSCPExp = `^git@(?P<host>.+):(?P<user>.+)/(?P<repo>.+).git` gitSCPExp = `^git@(?P<host>.+):(?P<user>.+)/(?P<repo>.+).git`
// The long ugly pattern for ${host} here is a generic pattern for "valid URL with zero or more subdomains and a valid TLD" // The long ugly pattern for ${host} here is a generic pattern for "valid URL with zero or more subdomains and a valid TLD"
gitHTTPSSubgroup = `(?P<host>[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P<user>[-_a-zA-Z0-9/]+)/(?P<repo>[-_a-zA-Z0-9]+)\.git` gitHTTPSSubgroup = `(?P<host>[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P<user>[-_a-zA-Z0-9/\.]+)/(?P<repo>[-_a-zA-Z0-9\.]+)\.git`
gitHTTPSExp = `(?P<host>[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P<user>[-_a-zA-Z0-9]+)/(?P<repo>[-_a-zA-Z0-9]+)` gitHTTPSExp = `(?P<host>[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P<user>[-_a-zA-Z0-9\.]+)/(?P<repo>[-_a-zA-Z0-9\.]+)`
) )
var ( var (

View file

@ -84,6 +84,23 @@ func TestParseGit(t *testing.T) {
}, },
wantRemote: "https://example.com/foo/bar.git", wantRemote: "https://example.com/foo/bar.git",
}, },
{
name: "ValidGitLabUserGroupHTTPS",
uri: "https://gitlab.example.com/first.last/project",
want: &Dependency{
Version: "master",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "gitlab.example.com",
User: "first.last",
Repo: "project",
Subdir: "",
},
},
},
wantRemote: "https://gitlab.example.com/first.last/project.git",
},
{ {
name: "ValidGitNoScheme", name: "ValidGitNoScheme",
uri: "example.com/foo/bar", uri: "example.com/foo/bar",