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-release b/git-flow-release
index 8cdeadb..b75891e 100644
--- a/git-flow-release
+++ b/git-flow-release
@@ -105,9 +105,19 @@
fi
}
+require_base_is_on_develop() {
+ if ! git branch --contains "$BASE" 2>/dev/null \
+ | sed 's/[* ] //g' \
+ | grep -q "^$DEVELOP_BRANCH\$"; then
+ die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'."
+ fi
+}
+
cmd_start() {
parse_args "$@"
+ BASE="${2:-$DEVELOP_BRANCH}"
require_version_arg
+ require_base_is_on_develop
# sanity checks
gitflow_require_clean_working_tree
@@ -118,11 +128,11 @@
gitflow_require_branch_absent $BRANCH
# create branch
- git checkout -b $BRANCH $DEVELOP_BRANCH
+ git checkout -b $BRANCH $BASE
echo
echo "Summary of actions:"
- echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
+ echo "- A new branch '$BRANCH' was created, based on '$BASE'"
echo "- You are now on branch '$BRANCH'"
echo
echo "Follow-up actions:"
@@ -130,7 +140,7 @@
echo "- Start committing last-minute fixes in preparing your release"
echo "- When done, run:"
echo
- echo " git flow finish release '$VERSION'"
+ echo " git flow release finish '$VERSION'"
echo
}