From 0ce74b07dd1c95704c4c54626759ea869fa70abe Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 30 Dec 2020 13:35:51 +0100 Subject: pkg/vcs: allow ~ in git repo URLs --- pkg/vcs/vcs.go | 6 +++--- pkg/vcs/vcs_test.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index d86e15f62..8e12bbca9 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -259,11 +259,11 @@ func runSandboxed(dir, command string, args ...string) ([]byte, error) { var ( // nolint: lll - gitLocalRepoRe = regexp.MustCompile(`^file:///[a-zA-Z0-9-_./]+(/)?$`) + gitLocalRepoRe = regexp.MustCompile(`^file:///[a-zA-Z0-9-_./~]+(/)?$`) // nolint: lll - gitRemoteRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)://[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[0-9]+)?(/[a-zA-Z0-9-_./]+)?(/)?$`) + gitRemoteRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)://[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[0-9]+)?(/[a-zA-Z0-9-_./~]+)?(/)?$`) // nolint: lll - gitSSHRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)@[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[a-zA-Z0-9-_]+)?(/[a-zA-Z0-9-_./]+)?(/)?$`) + gitSSHRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)@[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[a-zA-Z0-9-_]+)?(/[a-zA-Z0-9-_./~]+)?(/)?$`) gitBranchRe = regexp.MustCompile("^[a-zA-Z0-9-_/.]{2,200}$") gitHashRe = regexp.MustCompile("^[a-f0-9]{8,40}$") releaseTagRe = regexp.MustCompile(`^v([0-9]+).([0-9]+)(?:-rc([0-9]+))?(?:\.([0-9]+))?$`) diff --git a/pkg/vcs/vcs_test.go b/pkg/vcs/vcs_test.go index 5900ca046..23cfa1766 100644 --- a/pkg/vcs/vcs_test.go +++ b/pkg/vcs/vcs_test.go @@ -33,6 +33,7 @@ func TestCheckRepoAddress(t *testing.T) { "git://git.cmpxchg.org/linux-mmots.git": true, "https://anonscm.debian.org/git/kernel/linux.git": true, "git://kernel.ubuntu.com/ubuntu/ubuntu-zesty.git": true, + "git://git.armlinux.org.uk/~rmk/linux-arm.git": true, "http://host.xz:123/path/to/repo.git/": true, "https://chromium.googlesource.com/chromiumos/third_party/kernel": true, "https://fuchsia.googlesource.com": true, -- cgit mrf-deployment