Skip to content

Commit efa5b7f

Browse files
authored
Merge pull request #1290 from MusclePr/feature/netinstall-commit-option
[Feature] netinstall.sh add --commit and --tag options.
2 parents 5aec353 + 7611f62 commit efa5b7f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

netinstall.sh

100644100755
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@ args=()
1313
unstable=
1414
userinstall=
1515
userinstall2=
16+
commit=
1617

1718
for arg in "$@"; do
1819
case "$arg" in
1920
--unstable) unstable=1; ;;
2021
--repo=*) arkstGithubRepo="${arg#--repo=}"; ;;
2122
--perform-user-install) userinstall2=yes; ;;
2223
--yes-i-really-want-to-perform-a-user-install) userinstall=yes; ;;
24+
--commit=*) commit="${arg#--commit=}"; ;;
25+
--tag=*)
26+
tagname="${arg#--tag=}"
27+
commit="$(curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/tags/${tagname}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p')"
28+
if [ -z "$commit" ]; then
29+
echo "Tag ${tagname} not found"
30+
exit 1
31+
elif [ "$(echo "$commit" | wc -l)" -ne 1 ]; then
32+
echo "Tag ${tagname} is matched more than one tag."
33+
curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/tags/${tagname}" | sed -n 's/^ *"ref": "refs\/tags\/\(.*\)",.*/\1/p'
34+
exit 1
35+
fi
36+
echo "Tag ${tagname} found at commit ${commit}"
37+
;;
2338
*)
2439
if [[ -n "$channel" || "$arg" == --* ]]; then
2540
args+=("$arg")
@@ -128,7 +143,9 @@ function doInstallFromBranch(){
128143
# Download and untar installation files
129144
cd "$TEMP" || die "Unable to change to temporary directory"
130145

131-
if [ "$channel" = "master" ] && [ -z "$unstable" ]; then
146+
if [ -n "$commit" ]; then
147+
doInstallFromCommit "$commit" "${args[@]}"
148+
elif [ "$channel" = "master" ] && [ -z "$unstable" ]; then
132149
doInstallFromRelease "${args[@]}"
133150
else
134151
doInstallFromBranch "$channel" "${args[@]}"

0 commit comments

Comments
 (0)