refactor the whole thing
- now works as sub commands to git if copied to $(git --exec-path)
- now works with arbitrary commands for branch types
- consistent variable names
- new branch type 'support' for long-term support branches of historic
versions
- preliminary base branch support for hotfix branch type to create
hotfixes form support branches
diff --git a/git-flow-feature b/git-flow-feature
new file mode 100755
index 0000000..fc7a794
--- /dev/null
+++ b/git-flow-feature
@@ -0,0 +1,155 @@
+#
+# gitflow -- A collection of Git wrapper scripts to provide high-level
+# repository operations for Vincent Driessen's branching model:
+#
+# Original blog post presenting this model is found at:
+# http://nvie.com/archives/323
+#
+# Feel free to contribute to this project at:
+# http://github.com/nvie/gitflow
+#
+# Copyright (c) 2010 by Vincent Driessen
+# Copyright (c) 2010 by Benedikt Böhm
+#
+
+usage() {
+ echo "usage: git flow start feature <name> [<base>]"
+ echo " git flow finish feature <name> [<base>]"
+ echo " git flow publish feature <name>"
+ echo " git flow track feature <name>"
+ # TODO
+ #echo ""
+ #echo "options:"
+ #echo "--option Explanation"
+ #echo ""
+ #echo "start-only options:"
+ #echo "--option Explanation"
+ #echo ""
+ #echo "finish-only options:"
+ #echo "--rebase Rebases the feature branch on top of develop, instead of merging"
+ #echo "--squash Squashes all commits of the feature branch into a single commit"
+ #echo " on develop"
+ #echo "--push Push to the origin repo when finished"
+}
+
+parse_args() {
+ NAME="$1"
+ BASE="${2:-develop}"
+ if [ "$NAME" = "" ]; then
+ echo "Missing argument <name>."
+ usage
+ exit 1
+ fi
+ BRANCH=feature/$NAME
+}
+
+cmd_help() {
+ usage
+ exit 0
+}
+
+cmd_start() {
+ parse_args "$@"
+
+ # sanity checks
+ gitflow_check_clean_working_tree
+ gitflow_require_branch_absent $BRANCH
+ if [ "$BASE" = "develop" ]; then
+ git fetch origin develop
+ gitflow_require_branches_equal develop origin/develop
+ fi
+
+ # create branch
+ git checkout -b $BRANCH $BASE
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new branch '$BRANCH' was created, based on '$BASE'"
+ echo "- You are now on branch '$BRANCH'"
+ echo ""
+ echo "Now, start committing on your feature. When done, use:"
+ echo ""
+ echo " git flow finish feature $NAME"
+ echo
+}
+
+cmd_finish() {
+ parse_args "$@"
+
+ # sanity checks
+ gitflow_check_clean_working_tree
+ gitflow_require_branch $BRANCH
+ git fetch origin
+ if has origin/$BRANCH $REMOTE_BRANCHES; then
+ gitflow_require_branches_equal $BRANCH origin/$BRANCH
+ fi
+ if [ "$BASE" = "develop" ]; then
+ gitflow_require_branches_equal develop origin/develop
+ fi
+
+ # merge into BASE
+ git checkout $BASE
+ if [ "$(git rev-list -n2 $BASE..$BRANCH | wc -l)" = "1" ]; then
+ git merge --ff $BRANCH
+ else
+ git merge --no-ff $BRANCH
+ fi
+
+ # delete branch
+ # TODO: How do we handle merge conflicts here??
+ git push origin :refs/heads/$BRANCH
+ git branch -d $BRANCH
+
+ echo
+ echo "Summary of actions:"
+ echo "- The feature branch '$BRANCH' was merged into '$BASE'"
+ #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
+}
+
+cmd_publish() {
+ parse_args "$@"
+
+ # sanity checks
+ gitflow_check_clean_working_tree
+ gitflow_require_branch $BRANCH
+ git fetch origin
+ gitflow_require_branch_absent origin/$BRANCH
+
+ # create remote branch
+ git push origin $BRANCH:refs/heads/$BRANCH
+ git fetch origin
+
+ # configure remote tracking
+ 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"
+ echo "- The local branch '$BRANCH' was configured to track the remote branch"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
+cmd_track() {
+ parse_args "$@"
+
+ # sanity checks
+ gitflow_check_clean_working_tree
+ gitflow_require_branch_absent $BRANCH
+ git fetch origin
+ gitflow_require_branch origin/$BRANCH
+
+ # create tracking branch
+ git checkout -b $BRANCH origin/$BRANCH
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote tracking branch '$BRANCH' was created"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}