From 4a864fbc090c482c7c17fc304745867b2f89254b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 26 Jan 2010 12:59:27 +0100 Subject: [PATCH 1/3] make master and develop branch names configurable --- TODO.mdown | 1 - git-flow | 6 ++++-- git-flow-feature | 12 ++++++------ git-flow-hotfix | 20 ++++++++++---------- git-flow-release | 18 +++++++++--------- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/TODO.mdown b/TODO.mdown index 0bb08db..38c51bb 100644 --- a/TODO.mdown +++ b/TODO.mdown @@ -3,7 +3,6 @@ TODO-list General configuration --------------------- -- Support configurable naming for fixed branch names 'master' and 'develop' - Support configurable naming conventions (i.e. name prefixes) for supporting branches, instead of fixed 'release-\*' and 'hotfix-\*' diff --git a/git-flow b/git-flow index 7a5c4cc..0adac5c 100755 --- a/git-flow +++ b/git-flow @@ -18,6 +18,10 @@ if [ "$DEBUG" = "yes" ]; then set -x fi +export GITFLOW_DIR=$(dirname "$0") +export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master) +export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop) + warn() { echo "$@" >&2; } die() { warn "$@"; exit 1; } has() { [[ " ${*:2} " == *" $1 "* ]]; } @@ -36,8 +40,6 @@ main() { exit 1 fi - export GITFLOW_DIR=$(dirname "$0") - # sanity checks ACTION="$1" BTYPE="$2" diff --git a/git-flow-feature b/git-flow-feature index fc7a794..b48e893 100755 --- a/git-flow-feature +++ b/git-flow-feature @@ -34,7 +34,7 @@ usage() { parse_args() { NAME="$1" - BASE="${2:-develop}" + BASE="${2:-$DEVELOP_BRANCH}" if [ "$NAME" = "" ]; then echo "Missing argument ." usage @@ -54,9 +54,9 @@ cmd_start() { # 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 + if [ "$BASE" = "$DEVELOP_BRANCH" ]; then + git fetch origin $DEVELOP_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH fi # create branch @@ -83,8 +83,8 @@ cmd_finish() { 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 + if [ "$BASE" = "$DEVELOP_BRANCH" ]; then + gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH fi # merge into BASE diff --git a/git-flow-hotfix b/git-flow-hotfix index cf4e008..d5542f8 100755 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -29,7 +29,7 @@ usage() { parse_args() { VERSION="$1" - BASE="${2:-master}" + BASE="${2:-$MASTER_BRANCH}" if [ "$VERSION" = "" ]; then echo "Missing argument ." usage @@ -49,7 +49,7 @@ cmd_start() { # sanity checks gitflow_check_clean_working_tree git fetch origin - gitflow_require_branches_equal master origin/master + gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH gitflow_require_branch_absent $BRANCH # create branch @@ -74,10 +74,10 @@ cmd_finish() { # sanity checks gitflow_check_clean_working_tree - git fetch origin master - git fetch origin develop - gitflow_require_branches_equal master origin/master - gitflow_require_branches_equal develop origin/develop + git fetch origin $MASTER_BRANCH + git fetch origin $DEVELOP_BRANCH + gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH # merge into BASE git checkout $BASE @@ -86,8 +86,8 @@ cmd_finish() { # merge into develop if we fixed a master issue # TODO: merge into support branch - if [ "$BASE" = "master" ]; then - git checkout develop + if [ "$BASE" = "$MASTER_BRANCH" ]; then + git checkout $DEVELOP_BRANCH git merge --no-ff $BRANCH fi @@ -102,8 +102,8 @@ cmd_finish() { echo "- Latest objects have been fetched from 'origin'" echo "- Hotfix branch has been merged into '$BASE'" echo "- The hotfix was tagged 'v$VERSION'" - if [ "$BASE" = "master" ]; then - echo "- Hotfix branch has been back-merged into 'develop'" + if [ "$BASE" = "$MASTER_BRANCH" ]; then + echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'" fi echo "- Hotfix branch '$BRANCH' has been deleted" echo diff --git a/git-flow-release b/git-flow-release index 3f5683e..35b4fbe 100755 --- a/git-flow-release +++ b/git-flow-release @@ -49,15 +49,15 @@ cmd_start() { # sanity checks gitflow_check_clean_working_tree git fetch origin - gitflow_require_branches_equal develop origin/develop + gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH gitflow_require_branch_absent $BRANCH # create branch - git checkout -b $BRANCH develop + git checkout -b $BRANCH $DEVELOP_BRANCH echo echo "Summary of actions:" - echo "- A new branch '$BRANCH' was created, based on 'develop'" + echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'" echo "- You are now on branch '$BRANCH'" echo echo "Follow-up actions:" @@ -75,16 +75,16 @@ cmd_finish() { # sanity checks gitflow_check_clean_working_tree git fetch origin - gitflow_require_branches_equal master origin/master - gitflow_require_branches_equal develop origin/develop + gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH # merge into master - git checkout master + git checkout $MASTER_BRANCH git merge --no-ff $BRANCH git tag v$VERSION # merge into develop - git checkout develop + git checkout $DEVELOP_BRANCH git merge --no-ff $BRANCH # delete branch @@ -96,9 +96,9 @@ cmd_finish() { echo echo "Summary of actions:" echo "- Latest objects have been fetched from 'origin'" - echo "- Release branch has been merged into 'master'" + echo "- Release branch has been merged into '$MASTER_BRANCH'" echo "- The release was tagged 'v$VERSION'" - echo "- Release branch has been back-merged into 'develop'" + echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'" echo "- Release branch '$BRANCH' has been deleted" echo } From 350e7159f1b1e709bd71751f4c76f191884d098e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 26 Jan 2010 13:05:05 +0100 Subject: [PATCH 2/3] make origin configurable --- git-flow | 1 + git-flow-feature | 30 +++++++++++++++--------------- git-flow-hotfix | 14 +++++++------- git-flow-release | 12 ++++++------ git-flow-support | 6 +++--- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/git-flow b/git-flow index 0adac5c..283c779 100755 --- a/git-flow +++ b/git-flow @@ -21,6 +21,7 @@ fi export GITFLOW_DIR=$(dirname "$0") export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master) export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop) +export ORIGIN=$(git config --get gitflow.origin || echo origin) warn() { echo "$@" >&2; } die() { warn "$@"; exit 1; } diff --git a/git-flow-feature b/git-flow-feature index b48e893..cda9c90 100755 --- a/git-flow-feature +++ b/git-flow-feature @@ -55,8 +55,8 @@ cmd_start() { gitflow_check_clean_working_tree gitflow_require_branch_absent $BRANCH if [ "$BASE" = "$DEVELOP_BRANCH" ]; then - git fetch origin $DEVELOP_BRANCH - gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH + git fetch $ORIGIN $DEVELOP_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH fi # create branch @@ -79,12 +79,12 @@ cmd_finish() { # 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 + git fetch $ORIGIN + 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 + gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH fi # merge into BASE @@ -97,7 +97,7 @@ cmd_finish() { # delete branch # TODO: How do we handle merge conflicts here?? - git push origin :refs/heads/$BRANCH + git push $ORIGIN :refs/heads/$BRANCH git branch -d $BRANCH echo @@ -115,15 +115,15 @@ cmd_publish() { # sanity checks gitflow_check_clean_working_tree gitflow_require_branch $BRANCH - git fetch origin - gitflow_require_branch_absent origin/$BRANCH + git fetch $ORIGIN + gitflow_require_branch_absent $ORIGIN/$BRANCH # create remote branch - git push origin $BRANCH:refs/heads/$BRANCH - git fetch origin + git push $ORIGIN $BRANCH:refs/heads/$BRANCH + git fetch $ORIGIN # configure remote tracking - git config branch.$BRANCH.remote origin + git config branch.$BRANCH.remote $ORIGIN git config branch.$BRANCH.merge refs/heads/$BRANCH git checkout $BRANCH @@ -141,11 +141,11 @@ cmd_track() { # sanity checks gitflow_check_clean_working_tree gitflow_require_branch_absent $BRANCH - git fetch origin - gitflow_require_branch origin/$BRANCH + git fetch $ORIGIN + gitflow_require_branch $ORIGIN/$BRANCH # create tracking branch - git checkout -b $BRANCH origin/$BRANCH + git checkout -b $BRANCH $ORIGIN/$BRANCH echo echo "Summary of actions:" diff --git a/git-flow-hotfix b/git-flow-hotfix index d5542f8..a12619c 100755 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -48,8 +48,8 @@ cmd_start() { # sanity checks gitflow_check_clean_working_tree - git fetch origin - gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH + git fetch $ORIGIN + gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH gitflow_require_branch_absent $BRANCH # create branch @@ -74,10 +74,10 @@ cmd_finish() { # sanity checks gitflow_check_clean_working_tree - git fetch origin $MASTER_BRANCH - git fetch origin $DEVELOP_BRANCH - gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH - gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH + git fetch $ORIGIN $MASTER_BRANCH + git fetch $ORIGIN $DEVELOP_BRANCH + gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH # merge into BASE git checkout $BASE @@ -99,7 +99,7 @@ cmd_finish() { echo echo "Summary of actions:" - echo "- Latest objects have been fetched from 'origin'" + echo "- Latest objects have been fetched from '$ORIGIN'" echo "- Hotfix branch has been merged into '$BASE'" echo "- The hotfix was tagged 'v$VERSION'" if [ "$BASE" = "$MASTER_BRANCH" ]; then diff --git a/git-flow-release b/git-flow-release index 35b4fbe..ca5e360 100755 --- a/git-flow-release +++ b/git-flow-release @@ -48,8 +48,8 @@ cmd_start() { # sanity checks gitflow_check_clean_working_tree - git fetch origin - gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH + git fetch $ORIGIN + gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH gitflow_require_branch_absent $BRANCH # create branch @@ -74,9 +74,9 @@ cmd_finish() { # sanity checks gitflow_check_clean_working_tree - git fetch origin - gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH - gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH + git fetch $ORIGIN + gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH + gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH # merge into master git checkout $MASTER_BRANCH @@ -95,7 +95,7 @@ cmd_finish() { echo echo "Summary of actions:" - echo "- Latest objects have been fetched from 'origin'" + echo "- Latest objects have been fetched from '$ORIGIN'" echo "- Release branch has been merged into '$MASTER_BRANCH'" echo "- The release was tagged 'v$VERSION'" echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'" diff --git a/git-flow-support b/git-flow-support index a3fc91e..c48e357 100644 --- a/git-flow-support +++ b/git-flow-support @@ -42,9 +42,9 @@ cmd_start() { git checkout -b $BRANCH $BASE # publish branch - git push origin $BRANCH:refs/heads/$BRANCH - git fetch origin - git config branch.$BRANCH.remote origin + git push $ORIGIN $BRANCH:refs/heads/$BRANCH + git fetch $ORIGIN + git config branch.$BRANCH.remote $ORIGIN git config branch.$BRANCH.merge refs/heads/$BRANCH git co $BRANCH From 96f44c0781799a8ca2064b38ada41e21a054316e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 26 Jan 2010 13:09:32 +0100 Subject: [PATCH 3/3] make branch prefixes configurable --- TODO.mdown | 2 -- git-flow-feature | 3 ++- git-flow-hotfix | 3 ++- git-flow-release | 3 ++- git-flow-support | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/TODO.mdown b/TODO.mdown index 38c51bb..9516b0a 100644 --- a/TODO.mdown +++ b/TODO.mdown @@ -3,8 +3,6 @@ TODO-list General configuration --------------------- -- Support configurable naming conventions (i.e. name prefixes) for supporting - branches, instead of fixed 'release-\*' and 'hotfix-\*' Release branch support ---------------------- diff --git a/git-flow-feature b/git-flow-feature index cda9c90..6ba664f 100755 --- a/git-flow-feature +++ b/git-flow-feature @@ -40,7 +40,8 @@ parse_args() { usage exit 1 fi - BRANCH=feature/$NAME + PREFIX=$(git config --get gitflow.prefix.feature || echo feature/) + BRANCH=$PREFIX$NAME } cmd_help() { diff --git a/git-flow-hotfix b/git-flow-hotfix index a12619c..14ac662 100755 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -35,7 +35,8 @@ parse_args() { usage exit 1 fi - BRANCH=hotfix/$VERSION + PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/) + BRANCH=$PREFIX$VERSION } cmd_help() { diff --git a/git-flow-release b/git-flow-release index ca5e360..d42287d 100755 --- a/git-flow-release +++ b/git-flow-release @@ -35,7 +35,8 @@ parse_args() { usage exit 1 fi - BRANCH=release/$VERSION + PREFIX=$(git config --get gitflow.prefix.release || echo release/) + BRANCH=$PREFIX$VERSION } cmd_help() { diff --git a/git-flow-support b/git-flow-support index c48e357..55f595e 100644 --- a/git-flow-support +++ b/git-flow-support @@ -24,7 +24,8 @@ parse_args() { usage exit 1 fi - BRANCH=support/$VERSION + PREFIX=$(git config --get gitflow.prefix.support || echo support/) + BRANCH=$PREFIX$VERSION } cmd_help() {