Commit 4a864fbc authored by Benedikt Böhm's avatar Benedikt Böhm

make master and develop branch names configurable

parent 4ea07a2c
...@@ -3,7 +3,6 @@ TODO-list ...@@ -3,7 +3,6 @@ TODO-list
General configuration General configuration
--------------------- ---------------------
- Support configurable naming for fixed branch names 'master' and 'develop'
- Support configurable naming conventions (i.e. name prefixes) for supporting - Support configurable naming conventions (i.e. name prefixes) for supporting
branches, instead of fixed 'release-\*' and 'hotfix-\*' branches, instead of fixed 'release-\*' and 'hotfix-\*'
......
...@@ -18,6 +18,10 @@ if [ "$DEBUG" = "yes" ]; then ...@@ -18,6 +18,10 @@ if [ "$DEBUG" = "yes" ]; then
set -x set -x
fi 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; } warn() { echo "$@" >&2; }
die() { warn "$@"; exit 1; } die() { warn "$@"; exit 1; }
has() { [[ " ${*:2} " == *" $1 "* ]]; } has() { [[ " ${*:2} " == *" $1 "* ]]; }
...@@ -36,8 +40,6 @@ main() { ...@@ -36,8 +40,6 @@ main() {
exit 1 exit 1
fi fi
export GITFLOW_DIR=$(dirname "$0")
# sanity checks # sanity checks
ACTION="$1" ACTION="$1"
BTYPE="$2" BTYPE="$2"
......
...@@ -34,7 +34,7 @@ usage() { ...@@ -34,7 +34,7 @@ usage() {
parse_args() { parse_args() {
NAME="$1" NAME="$1"
BASE="${2:-develop}" BASE="${2:-$DEVELOP_BRANCH}"
if [ "$NAME" = "" ]; then if [ "$NAME" = "" ]; then
echo "Missing argument <name>." echo "Missing argument <name>."
usage usage
...@@ -54,9 +54,9 @@ cmd_start() { ...@@ -54,9 +54,9 @@ cmd_start() {
# sanity checks # sanity checks
gitflow_check_clean_working_tree gitflow_check_clean_working_tree
gitflow_require_branch_absent $BRANCH gitflow_require_branch_absent $BRANCH
if [ "$BASE" = "develop" ]; then if [ "$BASE" = "$DEVELOP_BRANCH" ]; then
git fetch origin develop git fetch origin $DEVELOP_BRANCH
gitflow_require_branches_equal develop origin/develop gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
fi fi
# create branch # create branch
...@@ -83,8 +83,8 @@ cmd_finish() { ...@@ -83,8 +83,8 @@ cmd_finish() {
if has origin/$BRANCH $REMOTE_BRANCHES; then if has origin/$BRANCH $REMOTE_BRANCHES; then
gitflow_require_branches_equal $BRANCH origin/$BRANCH gitflow_require_branches_equal $BRANCH origin/$BRANCH
fi fi
if [ "$BASE" = "develop" ]; then if [ "$BASE" = "$DEVELOP_BRANCH" ]; then
gitflow_require_branches_equal develop origin/develop gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
fi fi
# merge into BASE # merge into BASE
......
...@@ -29,7 +29,7 @@ usage() { ...@@ -29,7 +29,7 @@ usage() {
parse_args() { parse_args() {
VERSION="$1" VERSION="$1"
BASE="${2:-master}" BASE="${2:-$MASTER_BRANCH}"
if [ "$VERSION" = "" ]; then if [ "$VERSION" = "" ]; then
echo "Missing argument <version>." echo "Missing argument <version>."
usage usage
...@@ -49,7 +49,7 @@ cmd_start() { ...@@ -49,7 +49,7 @@ cmd_start() {
# sanity checks # sanity checks
gitflow_check_clean_working_tree gitflow_check_clean_working_tree
git fetch origin git fetch origin
gitflow_require_branches_equal master origin/master gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH
gitflow_require_branch_absent $BRANCH gitflow_require_branch_absent $BRANCH
# create branch # create branch
...@@ -74,10 +74,10 @@ cmd_finish() { ...@@ -74,10 +74,10 @@ cmd_finish() {
# sanity checks # sanity checks
gitflow_check_clean_working_tree gitflow_check_clean_working_tree
git fetch origin master git fetch origin $MASTER_BRANCH
git fetch origin develop git fetch origin $DEVELOP_BRANCH
gitflow_require_branches_equal master origin/master gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH
gitflow_require_branches_equal develop origin/develop gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
# merge into BASE # merge into BASE
git checkout $BASE git checkout $BASE
...@@ -86,8 +86,8 @@ cmd_finish() { ...@@ -86,8 +86,8 @@ cmd_finish() {
# merge into develop if we fixed a master issue # merge into develop if we fixed a master issue
# TODO: merge into support branch # TODO: merge into support branch
if [ "$BASE" = "master" ]; then if [ "$BASE" = "$MASTER_BRANCH" ]; then
git checkout develop git checkout $DEVELOP_BRANCH
git merge --no-ff $BRANCH git merge --no-ff $BRANCH
fi fi
...@@ -102,8 +102,8 @@ cmd_finish() { ...@@ -102,8 +102,8 @@ cmd_finish() {
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 "- Hotfix branch has been merged into '$BASE'"
echo "- The hotfix was tagged 'v$VERSION'" echo "- The hotfix was tagged 'v$VERSION'"
if [ "$BASE" = "master" ]; then if [ "$BASE" = "$MASTER_BRANCH" ]; then
echo "- Hotfix branch has been back-merged into 'develop'" echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
fi fi
echo "- Hotfix branch '$BRANCH' has been deleted" echo "- Hotfix branch '$BRANCH' has been deleted"
echo echo
......
...@@ -49,15 +49,15 @@ cmd_start() { ...@@ -49,15 +49,15 @@ cmd_start() {
# sanity checks # sanity checks
gitflow_check_clean_working_tree gitflow_check_clean_working_tree
git fetch origin git fetch origin
gitflow_require_branches_equal develop origin/develop gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
gitflow_require_branch_absent $BRANCH gitflow_require_branch_absent $BRANCH
# create branch # create branch
git checkout -b $BRANCH develop git checkout -b $BRANCH $DEVELOP_BRANCH
echo echo
echo "Summary of actions:" 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 "- You are now on branch '$BRANCH'"
echo echo
echo "Follow-up actions:" echo "Follow-up actions:"
...@@ -75,16 +75,16 @@ cmd_finish() { ...@@ -75,16 +75,16 @@ cmd_finish() {
# sanity checks # sanity checks
gitflow_check_clean_working_tree gitflow_check_clean_working_tree
git fetch origin git fetch origin
gitflow_require_branches_equal master origin/master gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH
gitflow_require_branches_equal develop origin/develop gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
# merge into master # merge into master
git checkout master git checkout $MASTER_BRANCH
git merge --no-ff $BRANCH git merge --no-ff $BRANCH
git tag v$VERSION git tag v$VERSION
# merge into develop # merge into develop
git checkout develop git checkout $DEVELOP_BRANCH
git merge --no-ff $BRANCH git merge --no-ff $BRANCH
# delete branch # delete branch
...@@ -96,9 +96,9 @@ cmd_finish() { ...@@ -96,9 +96,9 @@ cmd_finish() {
echo echo
echo "Summary of actions:" 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'" echo "- Release branch has been merged into '$MASTER_BRANCH'"
echo "- The release was tagged 'v$VERSION'" 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 "- Release branch '$BRANCH' has been deleted"
echo echo
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment