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.
This commit is contained in:
morganamilo 2018-08-02 22:55:48 +01:00
parent b3e647aee4
commit 161bc1a17a
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E

19
vcs.go
View file

@ -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)