Parcourir la source

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.
morganamilo il y a 6 ans
Parent
commit
161bc1a17a
1 fichiers modifiés avec 13 ajouts et 6 suppressions
  1. 13 6
      vcs.go

+ 13 - 6
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)