From 9ab0d94578af8e79b64809b07346db89a07b7f61 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 9 Feb 2012 00:50:15 +0100 Subject: archrelease: Validate tags before releasing Compare every single tag with a list of valid tags. This prevents broken releases which occurred whenever someone made a typo on the command line: $ ./archrelease community i686 ==> ERROR: archrelease: Invalid tag: "community" (use -f to force release) Since the list is used in the ZSH completion as well, break it out to a separate file and move it to "lib/". Also, add a command line parameter to allow for releasing to an unknown repository when necessary. Signed-off-by: Lukas Fleischer Signed-off-by: Pierre Schmitz --- archrelease.in | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'archrelease.in') diff --git a/archrelease.in b/archrelease.in index 40b6c09..5bc2c90 100644 --- a/archrelease.in +++ b/archrelease.in @@ -1,13 +1,32 @@ #!/bin/bash m4_include(lib/common.sh) +m4_include(lib/valid-tags.sh) -if [[ -z $1 ]]; then - echo 'Usage: archrelease ...' +# parse command line options +FORCE= +while getopts ':f' flag; do + case $flag in + f) FORCE=1 ;; + :) die "Option requires an argument -- '$OPTARG'" ;; + \?) die "Invalid option -- '$OPTARG'" ;; + esac +done +shift $(( OPTIND - 1 )) + +if ! (( $# )); then + echo 'Usage: archrelease [-f] ...' exit 1 fi -# TODO: validate repo is really repo-arch +# validate repo is really repo-arch +if [[ -z $FORCE ]]; then + for tag in "$@"; do + if ! in_array "$tag" "${_tags[@]}"; then + die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)' + fi + done +fi if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' -- cgit v1.2.3-54-g00ecf