Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 010252a8a96994689120732e375c83762c4c17d1 1 parent 9277024
@nvie authored
View
14 README.mdown
@@ -58,22 +58,28 @@ Example uses:
git flow feature start <name> [<base>]
git flow feature finish <name>
- (`base` is `develop` by default)
+ For feature branches, the `<base>` arg must be a commit on `develop`.
* To list/start/finish release branches, use:
git flow release
- git flow release start <release>
+ git flow release start <release> [<base>]
git flow release finish <release>
+ For release branches, the `<base>` arg must be a commit on `develop`.
+
* To list/start/finish hotfix branches, use:
git flow hotfix
- git flow hotfix start <release> [<base-release>]
+ git flow hotfix start <release> [<base>]
git flow hotfix finish <release>
+
+ For hotfix branches, the `<base>` arg must be a commit on `master`.
* To list/start support branches, use:
git flow support
- git flow support start <release> [<base-release>]
+ git flow support start <release> <base>
+
+ For support branches, the `<base>` arg must be a commit on `master`.
View
26 git-flow-feature
@@ -17,7 +17,7 @@ PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)
usage() {
echo "usage: git flow feature [list] [-v]"
echo " git flow feature start [-Fv] <name> [<base>]"
- echo " git flow feature finish [-rsFv] <name|nameprefix> [<base>]"
+ echo " git flow feature finish [-rsFv] <name|nameprefix>"
echo " git flow feature publish <name>"
echo " git flow feature track <name>"
echo " git flow feature diff <name|nameprefix>"
@@ -148,7 +148,6 @@ parse_args() {
# read arguments into global variables
NAME="$1"
- BASE="${2:-$DEVELOP_BRANCH}"
BRANCH=$PREFIX$NAME
}
@@ -156,6 +155,7 @@ cmd_start() {
DEFINE_boolean fetch false 'fetch from origin before performing local operation' F
DEFINE_boolean force false 'force creation of feature branch (ignores dirty working tree)' f
parse_args "$@"
+ BASE="${2:-$DEVELOP_BRANCH}"
require_name
# sanity checks
@@ -248,24 +248,22 @@ cmd_finish() {
if has $ORIGIN/$BRANCH $REMOTE_BRANCHES; then
gitflow_require_branches_equal $BRANCH $ORIGIN/$BRANCH
fi
- if [ "$BASE" = "$DEVELOP_BRANCH" ]; then
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
- fi
+ gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
# if the user wants to rebase, do that first
if flag rebase; then
- if ! git flow feature rebase "$NAME" "$BASE"; then
+ if ! git flow feature rebase "$NAME" "$DEVELOP_BRANCH"; then
warn "Finish was aborted due to conflicts during rebase."
warn "Please finish the rebase manually now."
warn "When finished, re-run:"
- warn " git flow feature finish '$NAME' '$BASE'"
+ warn " git flow feature finish '$NAME' '$DEVELOP_BRANCH'"
exit 1
fi
fi
# merge into BASE
- git checkout $BASE
- if [ "$(git rev-list -n2 $BASE..$BRANCH | wc -l)" -eq 1 ]; then
+ git checkout $DEVELOP_BRANCH
+ if [ "$(git rev-list -n2 $DEVELOP_BRANCH..$BRANCH | wc -l)" -eq 1 ]; then
git merge --ff $BRANCH
else
git merge --no-ff $BRANCH
@@ -273,9 +271,9 @@ cmd_finish() {
if [ $? -ne 0 ]; then
# oops.. we have a merge conflict!
- # write the given $BASE to a temporary file (we need it later)
+ # write the given $DEVELOP_BRANCH to a temporary file (we need it later)
mkdir -p "$GIT_DIR/.gitflow"
- echo "$BASE" > "$GIT_DIR/.gitflow/MERGE_BASE"
+ echo "$DEVELOP_BRANCH" > "$GIT_DIR/.gitflow/MERGE_BASE"
echo
echo "There were merge conflicts. To resolve the merge conflict manually, use:"
echo " git mergetool"
@@ -304,10 +302,10 @@ helper_finish_cleanup() {
echo
echo "Summary of actions:"
- echo "- The feature branch '$BRANCH' was merged into '$BASE'"
+ echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
echo "- Feature branch '$BRANCH' has been removed"
- echo "- You are now on branch '$BASE'"
+ echo "- You are now on branch '$DEVELOP_BRANCH'"
echo
}
@@ -380,5 +378,5 @@ cmd_rebase() {
if flag interactive; then
OPTS="$OPTS -i"
fi
- git rebase $OPTS "$BASE"
+ git rebase $OPTS "$DEVELOP_BRANCH"
}
View
44 git-flow-hotfix
@@ -19,17 +19,7 @@ FLAG_FETCH=1
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 @@ parse_args() {
# read arguments into global variables
VERSION="$1"
- BASE="${2:-$MASTER_BRANCH}"
BRANCH=$PREFIX$VERSION
}
@@ -110,8 +99,19 @@ require_version_arg() {
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 @@ cmd_start() {
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 @@ cmd_finish() {
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 @@ cmd_finish() {
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
}
View
16 git-flow-release
@@ -105,9 +105,19 @@ require_version_arg() {
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 @@ cmd_start() {
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 @@ cmd_start() {
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
}
View
33 git-flow-support
@@ -21,7 +21,7 @@ warn "note: DO NOT use it in a production situation."
usage() {
echo "usage: git flow support [list] [-v]"
- echo " git flow support start <version> [<base>]"
+ echo " git flow support start <version> <base>"
}
cmd_default() {
@@ -90,7 +90,7 @@ parse_args() {
# read arguments into global variables
VERSION="$1"
- BASE="${2:-${VERSION_PREFIX}${VERSION}}"
+ BASE="$2"
BRANCH=$PREFIX$VERSION
}
@@ -102,9 +102,27 @@ require_version_arg() {
fi
}
+require_base_arg() {
+ if [ "$BASE" = "" ]; then
+ warn "Missing argument <base>"
+ usage
+ exit 1
+ 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 "$@"
require_version_arg
+ require_base_arg
+ require_base_is_on_master
# sanity checks
gitflow_require_clean_working_tree
@@ -113,21 +131,14 @@ cmd_start() {
if [ $FLAG_FETCH -eq 1 ]; then
git fetch -q $ORIGIN $BASE
fi
+ gitflow_require_branch_absent $BRANCH
# create branch
git checkout -b "$BRANCH" "$BASE"
- # publish branch
- #git push $ORIGIN $BRANCH:refs/heads/$BRANCH
-
- git config branch.$BRANCH.remote $ORIGIN
- git config branch.$BRANCH.merge refs/heads/$BRANCH
- git checkout $BRANCH
-
echo
echo "Summary of actions:"
- echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
- echo "- A new tracking branch '$BRANCH' was created"
+ echo "- A new branch '$BRANCH' was created, based on '$BASE'"
echo "- You are now on branch '$BRANCH'"
echo
}
Please sign in to comment.
Something went wrong with that request. Please try again.