Merge pull request #760 from Morganamilo/fixprotocols

Use correct source protocol for VCS checks
This commit is contained in:
Anna 2018-10-09 01:24:57 +01:00 committed by GitHub
commit 5fe9160b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

13
vcs.go
View File

@ -62,7 +62,7 @@ func parseSource(source string) (url string, branch string, protocols []string)
if len(split) != 2 { if len(split) != 2 {
return "", "", nil return "", "", nil
} }
protocols = strings.Split(split[0], "+") protocols = strings.SplitN(split[0], "+", 2)
git := false git := false
for _, protocol := range protocols { for _, protocol := range protocols {
@ -72,6 +72,8 @@ func parseSource(source string) (url string, branch string, protocols []string)
} }
} }
protocols = protocols[len(protocols)-1:]
if !git { if !git {
return "", "", nil return "", "", nil
} }
@ -142,7 +144,8 @@ func updateVCSData(pkgName string, sources []gosrc.ArchString, mux *sync.Mutex,
} }
func getCommit(url string, branch string, protocols []string) string { func getCommit(url string, branch string, protocols []string) string {
for _, protocol := range protocols { if len(protocols) > 0 {
protocol := protocols[len(protocols)-1]
var outbuf bytes.Buffer var outbuf bytes.Buffer
cmd := passToGit("", "ls-remote", protocol+"://"+url, branch) cmd := passToGit("", "ls-remote", protocol+"://"+url, branch)
@ -151,7 +154,7 @@ func getCommit(url string, branch string, protocols []string) string {
err := cmd.Start() err := cmd.Start()
if err != nil { if err != nil {
continue return ""
} }
//for some reason //for some reason
@ -165,14 +168,14 @@ func getCommit(url string, branch string, protocols []string) string {
err = cmd.Wait() err = cmd.Wait()
timer.Stop() timer.Stop()
if err != nil { if err != nil {
continue return ""
} }
stdout := outbuf.String() stdout := outbuf.String()
split := strings.Fields(stdout) split := strings.Fields(stdout)
if len(split) < 2 { if len(split) < 2 {
continue return ""
} }
commit := split[0] commit := split[0]

View File

@ -44,7 +44,7 @@ func TestParsing(t *testing.T) {
} }
sources := []source{ sources := []source{
{"github.com/neovim/neovim.git", "HEAD", []string{"git", "https"}}, {"github.com/neovim/neovim.git", "HEAD", []string{"https"}},
{"github.com/jguer/yay.git", "master", []string{"git"}}, {"github.com/jguer/yay.git", "master", []string{"git"}},
{"github.com/davidgiven/ack", "HEAD", []string{"git"}}, {"github.com/davidgiven/ack", "HEAD", []string{"git"}},
{"", "", nil}, {"", "", nil},