Added an optional <base> argument to all start subactions.
The only exception to the rule is git-flow-support, which has an
explicitly required <base> argument (since we cannot deduce a sane default
name for base).
Furthermore, these <base> arguments are checked to refer to commits on:
- develop (for feature, release)
- master (for hotfix, support)
Removed any occurrences of optional <base> arguments in finish subactions.
The finishing target branches are clearly defined by the model. The <base>
argument will probably confuse users. If they want the power to merge
those feature branches into *other* branches then develop, for example,
they can still use the magical power of Git itself for that. Gitflow
should not provide such support.
diff --git a/git-flow-hotfix b/git-flow-hotfix
index d3c70ad..efc69a7 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -19,17 +19,7 @@
usage() {
echo "usage: git flow hotfix [list] [-v]"
echo " git flow hotfix start <version> [<base>]"
- echo " git flow hotfix finish <version> [<base>]"
- # TODO
- #echo ""
- #echo "options:"
- #echo "--option Explanation"
- #echo ""
- #echo "start-only options:"
- #echo "--option Explanation"
- #echo ""
- #echo "finish-only options:"
- #echo "--push Push to the origin repo when finished"
+ echo " git flow hotfix finish <version>"
}
cmd_default() {
@@ -98,7 +88,6 @@
# read arguments into global variables
VERSION="$1"
- BASE="${2:-$MASTER_BRANCH}"
BRANCH=$PREFIX$VERSION
}
@@ -110,8 +99,19 @@
fi
}
+require_base_is_on_master() {
+ if ! git branch --contains "$BASE" 2>/dev/null \
+ | sed 's/[* ] //g' \
+ | grep -q "^$MASTER_BRANCH\$"; then
+ die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'."
+ fi
+}
+
cmd_start() {
parse_args "$@"
+ BASE="${2:-$MASTER_BRANCH}"
+ require_version_arg
+ require_base_is_on_master
# sanity checks
gitflow_require_clean_working_tree
@@ -134,12 +134,13 @@
echo "- Start committing your hot fixes"
echo "- When done, run:"
echo
- echo " git flow finish hotfix '$HOTFIX_BRANCH'"
+ echo " git flow hotfix finish '$VERSION'"
echo
}
cmd_finish() {
parse_args "$@"
+ require_version_arg
# sanity checks
gitflow_require_clean_working_tree
@@ -150,17 +151,14 @@
gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
- # merge into BASE
- git checkout $BASE
+ # merge into master
+ git checkout $MASTER_BRANCH
git merge --no-ff $BRANCH
git tag $VERSION_PREFIX$VERSION
# merge into develop if we fixed a master issue
- # TODO: merge into support branch
- if [ "$BASE" = "$MASTER_BRANCH" ]; then
- git checkout $DEVELOP_BRANCH
- git merge --no-ff $BRANCH
- fi
+ git checkout $DEVELOP_BRANCH
+ git merge --no-ff $BRANCH
# delete branch
git branch -d $BRANCH
@@ -171,11 +169,9 @@
echo
echo "Summary of actions:"
echo "- Latest objects have been fetched from '$ORIGIN'"
- echo "- Hotfix branch has been merged into '$BASE'"
+ echo "- Hotfix branch has been merged into '$MASTER_BRANCH'"
echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'"
- if [ "$BASE" = "$MASTER_BRANCH" ]; then
- echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
- fi
+ echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
echo "- Hotfix branch '$BRANCH' has been deleted"
echo
}