use regex instead of prefix match to detect github remotes

this will allow the optimization to work for both ssh and https
This commit is contained in:
Benoit Gagnon 2019-09-28 11:23:15 -04:00
parent 76d85b1f49
commit 524c820a94

View file

@ -162,7 +162,8 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st
// Optimization for GitHub sources: download a tarball archive of the requested // Optimization for GitHub sources: download a tarball archive of the requested
// version instead of cloning the entire repository. Resolves the version to a // version instead of cloning the entire repository. Resolves the version to a
// commit SHA using the GitHub API. // commit SHA using the GitHub API.
if strings.HasPrefix(p.Source.Remote, "https://github.com/") { isGitHubRemote, err := regexp.MatchString(`^(https|ssh)://github\.com/.+$`, p.Source.Remote)
if isGitHubRemote {
archiveUrl := fmt.Sprintf("%s/archive/%s.tar.gz", p.Source.Remote, version) archiveUrl := fmt.Sprintf("%s/archive/%s.tar.gz", p.Source.Remote, version)
archiveFilepath := fmt.Sprintf("%s.tar.gz", tmpDir) archiveFilepath := fmt.Sprintf("%s.tar.gz", tmpDir)