From 251792fbb23c28f24449128f9a2e88033153ad40 Mon Sep 17 00:00:00 2001 From: Benoit Gagnon Date: Tue, 19 May 2020 16:55:33 -0400 Subject: [PATCH] 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. --- spec/v1/deps/git.go | 4 ++-- spec/v1/deps/git_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/spec/v1/deps/git.go b/spec/v1/deps/git.go index 9d0567d..862b20a 100644 --- a/spec/v1/deps/git.go +++ b/spec/v1/deps/git.go @@ -106,8 +106,8 @@ const ( gitSSHExp = `ssh://git@(?P.+)/(?P.+)/(?P.+).git` gitSCPExp = `^git@(?P.+):(?P.+)/(?P.+).git` // 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[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P[-_a-zA-Z0-9/]+)/(?P[-_a-zA-Z0-9]+)\.git` - gitHTTPSExp = `(?P[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P[-_a-zA-Z0-9]+)/(?P[-_a-zA-Z0-9]+)` + gitHTTPSSubgroup = `(?P[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P[-_a-zA-Z0-9/\.]+)/(?P[-_a-zA-Z0-9\.]+)\.git` + gitHTTPSExp = `(?P[a-zA-Z0-9][a-zA-Z0-9-\.]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,})/(?P[-_a-zA-Z0-9\.]+)/(?P[-_a-zA-Z0-9\.]+)` ) var ( diff --git a/spec/v1/deps/git_test.go b/spec/v1/deps/git_test.go index 7cbbdcd..969726f 100644 --- a/spec/v1/deps/git_test.go +++ b/spec/v1/deps/git_test.go @@ -84,6 +84,23 @@ func TestParseGit(t *testing.T) { }, 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", uri: "example.com/foo/bar",