From 1915ef519a5a87cde3d108f6e4f0fb0493ea2c8e Mon Sep 17 00:00:00 2001 From: Benoit Gagnon Date: Thu, 24 Oct 2019 11:06:36 -0400 Subject: [PATCH] relax the SHA1 regex to cover SHA1, SHA256 and any other length of SHA Signed-off-by: Benoit Gagnon --- pkg/git.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/git.go b/pkg/git.go index 54d74e5..3d4859a 100644 --- a/pkg/git.go +++ b/pkg/git.go @@ -153,7 +153,7 @@ func remoteResolveRef(ctx context.Context, remote string, ref string) (string, e if err != nil { return "", err } - commitShaPattern, _ := regexp.Compile("^([0-9a-f]{40})\\b") + commitShaPattern := regexp.MustCompile("^([0-9a-f]{40,})\\b") commitSha := commitShaPattern.FindString(b.String()) return commitSha, nil } @@ -176,9 +176,9 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st // but possible event that a ref is exactly 40 hex characters commitSha, err := remoteResolveRef(ctx, p.Source.Remote, version) - // If the ref resolution failed and "version" looks like a SHA1, assume it is one - // and proceed. - commitShaPattern := regexp.MustCompile("^([0-9a-f]{40})$") + // If the ref resolution failed and "version" looks like a SHA, + // assume it is one and proceed. + commitShaPattern := regexp.MustCompile("^([0-9a-f]{40,})$") if commitSha == "" && commitShaPattern.MatchString(version) { commitSha = version }