Signed-off-by: Matt Darfeuille <matd...@gmail.com> --- build/release | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/build/release b/build/release index c77d8ef4..63dbf4d4 100644 --- a/build/release +++ b/build/release @@ -33,6 +33,7 @@ # The -B option will attempt to determine automatically # the branch that needs to be checked out. # The default value for the -B option is master. +# The -b option will checkout the given branch. # ################################################################################ # C O N F I G U R A T I O N @@ -73,6 +74,7 @@ usage() echo " -a -- Append <VERSION> to the end of the message tag." echo " -u -- Execute the upload script." echo " -B -- Automatically determine which branch to checkout." + echo " -b <BRANCHNAME> -- Checkout the given branch." echo "Where <VERSION> is:" echo " <VERSION> -- Version for the new tag name." @@ -103,6 +105,22 @@ check_working_tree() # $1 = path of repository fi } +checkout_branch_func() +{ + CURRENT_BRANCH_NAME=$(git --git-dir=${1}/.git rev-parse --abbrev-ref HEAD) + + if git --git-dir=${1}/.git show-ref --quiet --verify -- "refs/heads/$CHECKOUT_BRANCH_NAME"; then + BRANCH_NAME=$CHECKOUT_BRANCH_NAME + + if [ $CURRENT_BRANCH_NAME != $BRANCH_NAME ]; then + echo "Checking out branch ${BRANCH_NAME}in ${1}/.git..." + + git --git-dir=${1}/.git checkout --quiet $BRANCH_NAME + [ $? -ne 0 ] && fatal_error "Failed to check out branch ${BRANCH_NAME} in ${1}/.git." + fi + fi +} + checkout_branch_auto_func() { CURRENT_BRANCH_NAME=$(git --git-dir=${1}/.git rev-parse --abbrev-ref HEAD) @@ -219,6 +237,22 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do checkout_branch_auto=Yes option=${option#B} ;; + b*) + option=${option#b} + + if [ -z "$option" -a $# -gt 0 ]; then + shift + option=$1 + fi + + if [ -n "$option" ]; then + CHECKOUT_BRANCH_NAME=$option + else + fatal_error "The -b option requires a value." + fi + + option= + ;; *) usage ;; @@ -253,6 +287,9 @@ esac if [ -n "$checkout_branch_auto" ]; then checkout_branch_auto_func $GIT checkout_branch_auto_func $GITRELEASEDIR +elif [ -n "$CHECKOUT_BRANCH_NAME" ]; then + checkout_branch_func $GIT + checkout_branch_func $GITRELEASEDIR fi if [ -z "$GIT_CODE_OBJECT" -a -z "$GIT_RELEASE_OBJECT" ]; then -- 2.13.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Shorewall-devel mailing list Shorewall-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/shorewall-devel