From df5e54bbafb23ac87ce691f135a30b035147dc14 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Wed, 31 Aug 2022 15:33:22 +0200 Subject: [PATCH] xrestricted: Allow specifying a branch to use instead of master --- void/xrestricted | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/void/xrestricted b/void/xrestricted index 0ed7196..7357ece 100755 --- a/void/xrestricted +++ b/void/xrestricted @@ -20,7 +20,7 @@ if [[ ! -d $PACKAGES_DIR ]]; then exit 1 fi -zparseopts -D -E h=help -help=help j:=jobs -jobs:=jobs +zparseopts -D -E h=help -help=help j:=jobs -jobs:=jobs b:=branch -branch:=branch if [[ $help ]]; then <<-HELP @@ -30,6 +30,10 @@ if [[ $help ]]; then Install restricted packages from a void source repo. Detected repo at: $VOID_PACKAGES_DIR + + Common options: + -j, --jobs N Number of jobs to use + -b, --branch B Use given branch instead of master HELP exit fi @@ -40,19 +44,20 @@ fi cd $PACKAGES_DIR +branch=${branch[2]:-master} check "Checking git branch..." -if [[ $(git rev-parse --abbrev-ref HEAD) != master ]]; then +if [[ $(git rev-parse --abbrev-ref HEAD) != $branch ]]; then if ! git diff --quiet; then - fail "not on master and working directory dirty, please fix manually" + fail "not on $branch and working directory dirty, please fix manually" exit 1 else - warn "not on master" - check "checking out master ..." - output=$(git checkout master 2>&1) + warn "not on $branch" + check "checking out $branch ..." + output=$(git checkout $branch 2>&1) [[ $? == 0 ]] && succeed || { fail $output && exit 1 } fi else - succeed "on master" + succeed "on $branch" fi packages=( $(ag -G 'template' restricted=yes srcpkgs/ | cut -d/ -f 2 | sort -u) )