Skip to content

Commit

Permalink
refactor git config calls to global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hollow committed Jan 27, 2010
1 parent 7672d99 commit 49dd62b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
5 changes: 2 additions & 3 deletions git-flow-feature
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)

usage() {
echo "usage: git flow feature"
echo " git flow feature start <name> [<base>]"
Expand Down Expand Up @@ -42,13 +44,10 @@ parse_args() {
usage
exit 1
fi
PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)
BRANCH=$PREFIX$NAME
}

cmd_default() {
# TODO: Refactor getting this prefix into a general function
PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)
FEATURE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
if [ -z "$FEATURE_BRANCHES" ]; then
warn "No feature branches exist."
Expand Down
5 changes: 2 additions & 3 deletions git-flow-hotfix
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)

usage() {
echo "usage: git flow hotfix"
echo " git flow hotfix start <version> [<base>]"
Expand All @@ -36,13 +38,10 @@ parse_args() {
usage
exit 1
fi
PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
BRANCH=$PREFIX$VERSION
}

cmd_default() {
# TODO: Refactor getting this prefix into a general function
PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
HOTFIX_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
if [ -z "$HOTFIX_BRANCHES" ]; then
warn "No hotfix branches exist."
Expand Down
7 changes: 3 additions & 4 deletions git-flow-release
Expand Up @@ -12,6 +12,9 @@
# Copyright (c) 2010 by Benedikt Böhm
#

VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.release || echo release/)

usage() {
echo "usage: git flow release"
echo " git flow release start <version>"
Expand All @@ -30,20 +33,16 @@ usage() {
}

parse_args() {
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
VERSION="$1"
if [ "$VERSION" = "" ]; then
echo "Missing argument <version>."
usage
exit 1
fi
PREFIX=$(git config --get gitflow.prefix.release || echo release/)
BRANCH=$PREFIX$VERSION
}

cmd_default() {
# TODO: Refactor getting this prefix into a general function
PREFIX=$(git config --get gitflow.prefix.release || echo release/)
RELEASE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
if [ -z "$RELEASE_BRANCHES" ]; then
warn "No release branches exist."
Expand Down
7 changes: 3 additions & 4 deletions git-flow-support
Expand Up @@ -12,27 +12,26 @@
# Copyright (c) 2010 by Benedikt Böhm
#

VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.support || echo support/)

usage() {
echo "usage: git flow support"
echo " git flow support start <version> [<base>]"
}

parse_args() {
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
VERSION="$1"
BASE="${2:-${VERSION_PREFIX}${VERSION}}"
if [ "$VERSION" = "" ]; then
echo "Missing argument <version>."
usage
exit 1
fi
PREFIX=$(git config --get gitflow.prefix.support || echo support/)
BRANCH=$PREFIX$VERSION
}

cmd_default() {
# TODO: Refactor getting this prefix into a general function
PREFIX=$(git config --get gitflow.prefix.support || echo support/)
SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
if [ -z "$SUPPORT_BRANCHES" ]; then
warn "No support branches exist."
Expand Down

0 comments on commit 49dd62b

Please sign in to comment.