summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-07-15 21:22:51 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-07-15 21:37:23 +0200
commit2caa6db525230fa4d3fa0a649f48dc646e618d80 (patch)
tree954634b1bb03838c57a75be56a48ee3d0335a46d
parentac925c6f77b1248645e9784c15c48203877b77c7 (diff)
Add flag for not checking out a new branch
-rwxr-xr-xnix-script-update-package-def.sh34
1 files changed, 25 insertions, 9 deletions
diff --git a/nix-script-update-package-def.sh b/nix-script-update-package-def.sh
index d0d068d..cbe2f73 100755
--- a/nix-script-update-package-def.sh
+++ b/nix-script-update-package-def.sh
@@ -12,12 +12,13 @@ source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh
usage() {
cat <<EOS
- $(help_synopsis "${BASH_SOURCE[0]}" "[-y] [-b] [-g <nixpkgs path>] -u <url>")
+ $(help_synopsis "${BASH_SOURCE[0]}" "[-y] [-b] [-c] [-g <nixpkgs path>] -u <url>")
-y Don't ask before executing things (optional) (not implemented yet)
-b Also test-build the package (optional)
-u <url> Download and apply this url
-g <path> Path of nixpkgs clone (defaults to ./)
+ -c Don't check out another branch for update
-h Show this help and exit
Helper for developers of Nix packages.
@@ -53,8 +54,9 @@ YES=0
TESTBUILD=0
NIXPKGS=
URL=
+CHECKOUT=1
-while getopts "ybu:g:h" OPTION
+while getopts "ybu:g:ch" OPTION
do
case $OPTION in
y)
@@ -77,6 +79,11 @@ do
stdout "NIXPKGS = $NIXPKGS"
;;
+ c)
+ CHECKOUT=0
+ stdout "CHECKOUT = $CHECKOUT"
+ ;;
+
h)
usage
exit 0
@@ -125,7 +132,9 @@ then
fi
CURRENT_BRANCH=$(__git_current_branch "$NIXPKGS")
-__git "$NIXPKGS" checkout -b update-$PKG
+
+[[ $CHECKOUT == 1 ]] && __git "$NIXPKGS" checkout -b update-$PKG || true
+
if [[ $? -ne 0 ]]
then
stderr "Switching to branch update-$PKG failed."
@@ -140,12 +149,19 @@ then
ask_execute "Build '$PKG' in nixpkgs clone at '$NIXPKGS'" nix-build -A $PKG -I $NIXPKGS
fi
-stdout "Switching back to old commit which was current before we started."
-stdout "Switching to '$CURRENT_BRANCH'"
-__git "$NIXPKGS" checkout $CURRENT_BRANCH
-if [[ $? -ne 0 ]]
+#
+# If we checked out a new branch, we go back, too.
+#
+if [[ $CHECKOUT == 1 ]]
then
- stderr "Switching back to '$CURRENT_BRANCH' failed. Please check manually"
- exit 1
+ stdout "Switching back to old commit which was current before we started."
+ stdout "Switching to '$CURRENT_BRANCH'"
+ __git "$NIXPKGS" checkout $CURRENT_BRANCH
+
+ if [[ $? -ne 0 ]]
+ then
+ stderr "Switching back to '$CURRENT_BRANCH' failed. Please check manually"
+ exit 1
+ fi
fi