Commit 8fee0c22 authored by Guillaume-Jean Herbiet's avatar Guillaume-Jean Herbiet Committed by Vincent Driessen

Added -k option to keep (feature|hotfix|relase) branch when calling 'finish'.

parent 9510b694
...@@ -44,7 +44,7 @@ PREFIX=$(git config --get gitflow.prefix.feature) ...@@ -44,7 +44,7 @@ PREFIX=$(git config --get gitflow.prefix.feature)
usage() { usage() {
echo "usage: git flow feature [list] [-v]" echo "usage: git flow feature [list] [-v]"
echo " git flow feature start [-F] <name> [<base>]" echo " git flow feature start [-F] <name> [<base>]"
echo " git flow feature finish [-rF] <name|nameprefix>" echo " git flow feature finish [-rFk] <name|nameprefix>"
echo " git flow feature publish <name>" echo " git flow feature publish <name>"
echo " git flow feature track <name>" echo " git flow feature track <name>"
echo " git flow feature diff [<name|nameprefix>]" echo " git flow feature diff [<name|nameprefix>]"
...@@ -180,7 +180,7 @@ parse_args() { ...@@ -180,7 +180,7 @@ parse_args() {
parse_cmdline "$@" parse_cmdline "$@"
# read arguments into global variables # read arguments into global variables
NAME=$1 NAME=${!#}
BRANCH=$PREFIX$NAME BRANCH=$PREFIX$NAME
} }
...@@ -232,6 +232,7 @@ cmd_start() { ...@@ -232,6 +232,7 @@ cmd_start() {
cmd_finish() { cmd_finish() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
DEFINE_boolean rebase false 'rebase instead of merge' r DEFINE_boolean rebase false 'rebase instead of merge' r
DEFINE_boolean keep false 'keep branch after performing finish' k
parse_args "$@" parse_args "$@"
expand_nameprefix_arg expand_nameprefix_arg
...@@ -343,13 +344,23 @@ helper_finish_cleanup() { ...@@ -343,13 +344,23 @@ helper_finish_cleanup() {
if flag fetch; then if flag fetch; then
git push "$ORIGIN" ":refs/heads/$BRANCH" git push "$ORIGIN" ":refs/heads/$BRANCH"
fi fi
git branch -D "$BRANCH"
if flag keep; then
echo "Keep this branch" > /dev/null
else
git branch -d "$BRANCH"
fi
echo echo
echo "Summary of actions:" echo "Summary of actions:"
echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'" echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
echo "- Feature branch '$BRANCH' has been removed" if flag keep; then
echo "- Feature branch '$BRANCH' has been kept"
else
echo "- Feature branch '$BRANCH' has been removed"
fi
echo "- You are now on branch '$DEVELOP_BRANCH'" echo "- You are now on branch '$DEVELOP_BRANCH'"
echo echo
} }
......
...@@ -45,7 +45,7 @@ PREFIX=$(git config --get gitflow.prefix.hotfix) ...@@ -45,7 +45,7 @@ PREFIX=$(git config --get gitflow.prefix.hotfix)
usage() { usage() {
echo "usage: git flow hotfix [list] [-v]" echo "usage: git flow hotfix [list] [-v]"
echo " git flow hotfix start [-F] <version> [<base>]" echo " git flow hotfix start [-F] <version> [<base>]"
echo " git flow hotfix finish [-Fsump] <version>" echo " git flow hotfix finish [-Fsumpk] <version>"
} }
cmd_default() { cmd_default() {
...@@ -124,7 +124,7 @@ parse_args() { ...@@ -124,7 +124,7 @@ parse_args() {
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
# read arguments into global variables # read arguments into global variables
VERSION=$1 VERSION=${!#}
BRANCH=$PREFIX$VERSION BRANCH=$PREFIX$VERSION
} }
...@@ -194,6 +194,7 @@ cmd_finish() { ...@@ -194,6 +194,7 @@ cmd_finish() {
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m DEFINE_string message "" "use the given tag message" m
DEFINE_boolean push false "push to $ORIGIN after performing finish" p DEFINE_boolean push false "push to $ORIGIN after performing finish" p
DEFINE_boolean keep false 'keep branch after performing finish' k
parse_args "$@" parse_args "$@"
require_version_arg require_version_arg
...@@ -257,7 +258,11 @@ cmd_finish() { ...@@ -257,7 +258,11 @@ cmd_finish() {
fi fi
# delete branch # delete branch
git branch -d "$BRANCH" if flag keep; then
echo "Keep this branch" > /dev/null
else
git branch -d "$BRANCH"
fi
if flag push; then if flag push; then
git push "$ORIGIN" "$DEVELOP_BRANCH" || \ git push "$ORIGIN" "$DEVELOP_BRANCH" || \
...@@ -274,7 +279,11 @@ cmd_finish() { ...@@ -274,7 +279,11 @@ cmd_finish() {
echo "- Hotfix branch has been merged into '$MASTER_BRANCH'" echo "- Hotfix branch has been merged into '$MASTER_BRANCH'"
echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'" echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'"
echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'" echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
echo "- Hotfix branch '$BRANCH' has been deleted" if flag keep; then
echo "- Hotfix branch '$BRANCH' has been kept"
else
echo "- Hotfix branch '$BRANCH' has been deleted"
fi
if flag push; then if flag push; then
echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'"
fi fi
......
...@@ -45,7 +45,7 @@ PREFIX=$(git config --get gitflow.prefix.release) ...@@ -45,7 +45,7 @@ PREFIX=$(git config --get gitflow.prefix.release)
usage() { usage() {
echo "usage: git flow release [list] [-v]" echo "usage: git flow release [list] [-v]"
echo " git flow release start [-F] <version>" echo " git flow release start [-F] <version>"
echo " git flow release finish [-Fsump] <version>" echo " git flow release finish [-Fsumpk] <version>"
echo " git flow release publish <name>" echo " git flow release publish <name>"
echo " git flow release track <name>" echo " git flow release track <name>"
} }
...@@ -121,7 +121,7 @@ parse_args() { ...@@ -121,7 +121,7 @@ parse_args() {
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
# read arguments into global variables # read arguments into global variables
VERSION=$1 VERSION=${!#}
BRANCH=$PREFIX$VERSION BRANCH=$PREFIX$VERSION
} }
...@@ -197,6 +197,7 @@ cmd_finish() { ...@@ -197,6 +197,7 @@ cmd_finish() {
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m DEFINE_string message "" "use the given tag message" m
DEFINE_boolean push false "push to $ORIGIN after performing finish" p DEFINE_boolean push false "push to $ORIGIN after performing finish" p
DEFINE_boolean keep false 'keep branch after performing finish' k
parse_args "$@" parse_args "$@"
require_version_arg require_version_arg
...@@ -262,7 +263,11 @@ cmd_finish() { ...@@ -262,7 +263,11 @@ cmd_finish() {
fi fi
# delete branch # delete branch
git branch -d "$BRANCH" if flag keep; then
echo "Keep this branch" > /dev/null
else
git branch -d "$BRANCH"
fi
if flag push; then if flag push; then
git push "$ORIGIN" "$DEVELOP_BRANCH" || \ git push "$ORIGIN" "$DEVELOP_BRANCH" || \
...@@ -281,7 +286,11 @@ cmd_finish() { ...@@ -281,7 +286,11 @@ cmd_finish() {
echo "- Release branch has been merged into '$MASTER_BRANCH'" echo "- Release branch has been merged into '$MASTER_BRANCH'"
echo "- The release was tagged '$tagname'" echo "- The release was tagged '$tagname'"
echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'" echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
echo "- Release branch '$BRANCH' has been deleted" if flag keep; then
echo "- Release branch '$BRANCH' has been kept"
else
echo "- Release branch '$BRANCH' has been deleted"
fi
if flag push; then if flag push; then
echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'"
echo "- Release branch '$BRANCH' in '$ORIGIN' has been deleted." echo "- Release branch '$BRANCH' in '$ORIGIN' has been deleted."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment