From 676e5563b9319f0db08908af618df02efa6fcf66 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 17 Feb 2017 21:49:29 -0600 Subject: [PATCH] Only allow integers for input to github-apply Remove some unneded code from github-remove --- scripts/github-apply | 9 ++++----- scripts/github-remove | 6 ------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/github-apply b/scripts/github-apply index 16af1677ee..2343ebe293 100755 --- a/scripts/github-apply +++ b/scripts/github-apply @@ -3,8 +3,7 @@ LIBRENMS_DIR=`dirname "$(readlink -f "$0/..")"` cd $LIBRENMS_DIR -if [ -z "$1" ]; then - echo "You must specify a PR number to apply a patch" -else - curl https://patch-diff.githubusercontent.com/raw/librenms/librenms/pull/${1}.patch | git apply -v ${2} -fi +case $1 in + ''|*[!0-9]*) echo "You must specify a PR number to apply a patch" ;; + *) curl -s https://patch-diff.githubusercontent.com/raw/librenms/librenms/pull/${1}.patch | git apply -v ${2} ;; +esac diff --git a/scripts/github-remove b/scripts/github-remove index 278745e37e..d05fa7a755 100755 --- a/scripts/github-remove +++ b/scripts/github-remove @@ -18,7 +18,6 @@ def confirm(question): sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n').\n") - librenms_dir = dirname(dirname(abspath(__file__))) parser = argparse.ArgumentParser() @@ -27,13 +26,8 @@ group.add_argument("-d", "--discard", action="store_true", help="Discard all cha group.add_argument("-s", "--save", action="store_true", help="Save and remove changes by stashing them. (git stash)") group.add_argument("-r", "--restore", action="store_true", help="Attempt to restore saved changes (git stash pop)") parser.add_argument("-v", "--vendor", action="store_true", help="Also discard changes to ./vendor (requires --discard)") - args = parser.parse_args() -if args.vendor and not args.discard: - print(__file__ + ": error: argument -v/--vendor requires -d/--discard") - exit(1) - if args.discard: if confirm("Are you sure you want to delete all modified and untracked files?"):