Signed-off-by: Matt Darfeuille <[email protected]>
---
build/release | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/build/release b/build/release
index 747cf9bc..c77d8ef4 100644
--- a/build/release
+++ b/build/release
@@ -30,6 +30,9 @@
# in the code and release repository.
# If both options -c and -r are not given
# the default value of the 'git tag' command will be used.
+# 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.
#
################################################################################
# C O N F I G U R A T I O N
@@ -69,6 +72,7 @@ usage()
echo " -r -- Object that the new tag will refer to (release repository)."
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 "Where <VERSION> is:"
echo " <VERSION> -- Version for the new tag name."
@@ -99,6 +103,31 @@ check_working_tree() # $1 = path of repository
fi
}
+checkout_branch_auto_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/$(printf "%.5s" $VERSION)"; then
+ BRANCH_NAME=$(printf "%.5s" $VERSION)
+
+ 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
+ else
+ BRANCH_NAME=master
+
+ 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
+}
+
create_tag() # $1 = path of repository, $2 = object
{
if check_working_tree $1; then
@@ -186,6 +215,10 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
APPEND_VERSION=Yes
option=${option#v}
;;
+ B*)
+ checkout_branch_auto=Yes
+ option=${option#B}
+ ;;
*)
usage
;;
@@ -217,6 +250,11 @@ case $VERSION in
;;
esac
+if [ -n "$checkout_branch_auto" ]; then
+ checkout_branch_auto_func $GIT
+ checkout_branch_auto_func $GITRELEASEDIR
+fi
+
if [ -z "$GIT_CODE_OBJECT" -a -z "$GIT_RELEASE_OBJECT" ]; then
create_tag $GIT
create_tag $GITRELEASEDIR
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-devel