aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAlexander Egorenkov <Alexander.Egorenkov@ibm.com>2020-10-02 13:43:43 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-10-02 15:43:46 +0200
commit3297cdf8bb4d530c6c3bdc2111dac112b892fdf9 (patch)
tree74b80218a439fb50cf38ea8eb77e132285bc6d0f /pkg
parent062c9832a6cdb39bf38ad7a6dad51300a2e9a734 (diff)
pkg/vcs: support git URL starting with file:///
For use inside a Docker container e.g. Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/vcs/vcs.go8
-rw-r--r--pkg/vcs/vcs_test.go1
2 files changed, 7 insertions, 2 deletions
diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go
index 4f1887549..a7c1c0ed5 100644
--- a/pkg/vcs/vcs.go
+++ b/pkg/vcs/vcs.go
@@ -213,7 +213,9 @@ func Patch(dir string, patch []byte) error {
// CheckRepoAddress does a best-effort approximate check of a git repo address.
func CheckRepoAddress(repo string) bool {
- return gitRepoRe.MatchString(repo) || gitSSHRepoRe.MatchString(repo)
+ return gitLocalRepoRe.MatchString(repo) ||
+ gitRemoteRepoRe.MatchString(repo) ||
+ gitSSHRepoRe.MatchString(repo)
}
// CheckBranch does a best-effort approximate check of a git branch name.
@@ -236,7 +238,9 @@ func runSandboxed(dir, command string, args ...string) ([]byte, error) {
var (
// nolint: lll
- gitRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)://[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[0-9]+)?(/[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-_./]+)?(/)?$`)
// 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-_./]+)?(/)?$`)
gitBranchRe = regexp.MustCompile("^[a-zA-Z0-9-_/.]{2,200}$")
diff --git a/pkg/vcs/vcs_test.go b/pkg/vcs/vcs_test.go
index 7cfb7347a..5900ca046 100644
--- a/pkg/vcs/vcs_test.go
+++ b/pkg/vcs/vcs_test.go
@@ -37,6 +37,7 @@ func TestCheckRepoAddress(t *testing.T) {
"https://chromium.googlesource.com/chromiumos/third_party/kernel": true,
"https://fuchsia.googlesource.com": true,
"git@my-github.com:my/fd.git": true,
+ "file:///repo/linux.git": true,
"git@my-github.com:/fd.git": false,
"gitgit@my-github:/fd.git": false,
"git@my-github/fd.git": false,