From 161bc1a17a7207062779bb298c45fc8aff6fa008 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Thu, 2 Aug 2018 22:55:48 +0100 Subject: [PATCH] Only check pkgbuild source protocols for vcs fetch The current check involves checking the entire source url for the word git. This can lead to yay asumming sources are git repos when they are not. For example: https://raw.githubusercontent.com/ryanoasis/nerd-fonts/v2.0.0/LICENSE/ Makepkg seems to also only respect the protocols. For example: https://github.com/jguer/yay will be fetched as a web page. git:// or git+https:// would be needed. Although this does not seem to work the way yay assumes. You can not simply + togther a bunch of protocols. For exaplle: git+http+https:// will not work, even though individually they do. git must also come first: https+git:// will not work either. Yay's method of spliting on each + is fine though, it works and I'm not going to worry about broken packages that do https+git:// or similar. --- vcs.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/vcs.go b/vcs.go index 4b6cef70..9ba31072 100644 --- a/vcs.go +++ b/vcs.go @@ -64,11 +64,6 @@ func createDevelDB() error { // parseSource returns the git url, default branch and protocols it supports func parseSource(source string) (url string, branch string, protocols []string) { - if !(strings.Contains(source, "git://") || - strings.Contains(source, ".git") || - strings.Contains(source, "git+https://")) { - return "", "", nil - } split := strings.Split(source, "::") source = split[len(split)-1] split = strings.SplitN(source, "://", 2) @@ -76,8 +71,20 @@ func parseSource(source string) (url string, branch string, protocols []string) if len(split) != 2 { return "", "", nil } - protocols = strings.Split(split[0], "+") + + git := false + for _, protocol := range protocols { + if protocol == "git" { + git = true + break + } + } + + if !git { + return "", "", nil + } + split = strings.SplitN(split[1], "#", 2) if len(split) == 2 { secondSplit := strings.SplitN(split[1], "=", 2)