Przeglądaj źródła

Add support for direct building of a URL

This allows for things like: (to build test a PR branch directly)
```console
$ ./build.sh https://raw.githubusercontent.com/infosiftr/stackbrew/redis/library/redis
```

Or: (to build test just one tag of a PR branch)
```console
$ ./build.sh https://raw.githubusercontent.com/infosiftr/stackbrew/redis/library/redis:2.6
```
Tianon Gravi 11 lat temu
rodzic
commit
d0b9251b6e
1 zmienionych plików z 26 dodań i 8 usunięć
  1. 26 8
      bashbrew/build.sh

+ 26 - 8
bashbrew/build.sh

@@ -112,17 +112,35 @@ for repoTag in "${repos[@]}"; do
 	tag="${repoTag#*:}"
 	[ "$repo" != "$tag" ] || tag=
 	
-	if [ -f "$repo" ]; then
-		repoFile="$repo"
-		repo="$(basename "$repoFile")"
+	if [ "$repo" = 'http' -o "$repo" = 'https' ] && [[ "$tag" == //* ]]; then
+		# IT'S A URL!
+		repoUrl="$repo:${tag%:*}"
+		repo="$(basename "$repoUrl")"
+		if [ "${tag##*:}" != "$tag" ]; then
+			tag="${tag##*:}"
+		else
+			tag=
+		fi
 		repoTag="${repo}${tag:+:$tag}"
+		
+		echo "$repoTag ($repoUrl)" >> "$logDir/repos.txt"
+		
+		cmd=( curl -sSL --compressed "$repoUrl" )
 	else
-		repoFile="$library/$repo"
+		if [ -f "$repo" ]; then
+			repoFile="$repo"
+			repo="$(basename "$repoFile")"
+			repoTag="${repo}${tag:+:$tag}"
+		else
+			repoFile="$library/$repo"
+		fi
+		
+		repoFile="$(readlink -f "$repoFile")"
+		echo "$repoTag ($repoFile)" >> "$logDir/repos.txt"
+		
+		cmd=( cat "$repoFile" )
 	fi
 	
-	repoFile="$(readlink -f "$repoFile")"
-	echo "$repoTag ($repoFile)" >> "$logDir/repos.txt"
-	
 	if [ "${repoGitRepo[$repoTag]}" ]; then
 		queue+=( "$repoTag" )
 		continue
@@ -130,7 +148,7 @@ for repoTag in "${repos[@]}"; do
 	
 	# parse the repo library file
 	IFS=$'\n'
-	repoTagLines=( $(cat "$repoFile" | grep -vE '^#|^\s*$') )
+	repoTagLines=( $("${cmd[@]}" | grep -vE '^#|^\s*$') )
 	unset IFS
 	
 	tags=()