Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature/config alias #155

Open
wants to merge 5 commits into from

2 participants

@algernon

This patch implements support for multiple workflow setups within a single tree, the way it is explained in #154.

and others added some commits
@nvie Merge branch 'hotfix/0.2.1' f8ea3eb
@nvie Merge branch 'release/0.3' 298514b
@nvie Merge branch 'release/0.4' dc5d08d
@nvie Merge branch 'release/0.4.1' 1ffb6b1
@algernon algernon Support setting "aliases", so one can have multiple workflows in the …
…same tree

To support multiple workflows in the same tree, allow the use of
either symlinks or GIT_FLOW_SELF to select between flows.

This allows one to, for example, set GIT_FLOW_SELF to git-flow-debian,
in which case git flow will look for the gitflow-debian settings in
git config, instead of gitflow.

This, in turn, makes it possible to have a different workflow setup
for upstream development, and packaging development.

All this is accomplished with the introduction of a gitflow_config
function, that does the heavy lifting, and everything that used git
config gitflow.*, will now use git config $(gitflow_config).*.

Requested-By: Holger Levsen <holger@layer-acht.org>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
bed0b0d
@asnowfix asnowfix referenced this pull request from a commit in asnowfix/gitflow
@petervanderdoes petervanderdoes Hooks directory needs to be absolute in config.
During setup the hooks directory suggests a relative path to the root of the repository.
When you execute a git flow command in a subdirectory any hooks and filters won't be executed as the files can't be found.

Fixes: #155
b4faada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 19, 2010
  1. Merge branch 'hotfix/0.2.1'

    authored
Commits on Jul 22, 2010
  1. Merge branch 'release/0.3'

    authored
Commits on Oct 18, 2010
  1. Merge branch 'release/0.4'

    authored
Commits on Feb 14, 2011
  1. Merge branch 'release/0.4.1'

    authored
Commits on Sep 20, 2011
  1. @algernon

    Support setting "aliases", so one can have multiple workflows in the …

    algernon authored
    …same tree
    
    To support multiple workflows in the same tree, allow the use of
    either symlinks or GIT_FLOW_SELF to select between flows.
    
    This allows one to, for example, set GIT_FLOW_SELF to git-flow-debian,
    in which case git flow will look for the gitflow-debian settings in
    git config, instead of gitflow.
    
    This, in turn, makes it possible to have a different workflow setup
    for upstream development, and packaging development.
    
    All this is accomplished with the introduction of a gitflow_config
    function, that does the heavy lifting, and everything that used git
    config gitflow.*, will now use git config $(gitflow_config).*.
    
    Requested-By: Holger Levsen <holger@layer-acht.org>
    Signed-off-by: Gergely Nagy <algernon@balabit.hu>
This page is out of date. Refresh to see the latest.
View
2  git-flow-feature
@@ -39,7 +39,7 @@
require_git_repo
require_gitflow_initialized
gitflow_load_settings
-PREFIX=$(git config --get gitflow.prefix.feature)
+PREFIX=$(git config --get $(gitflow_config).prefix.feature)
usage() {
echo "usage: git flow feature [list] [-v]"
View
4 git-flow-hotfix
@@ -39,8 +39,8 @@
require_git_repo
require_gitflow_initialized
gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.hotfix)
+VERSION_PREFIX=$(eval "echo `git config --get $(gitflow_config).prefix.versiontag`")
+PREFIX=$(git config --get $(gitflow_config).prefix.hotfix)
usage() {
echo "usage: git flow hotfix [list] [-v]"
View
56 git-flow-init
@@ -76,7 +76,7 @@ cmd_default() {
# add a master branch if no such branch exists yet
local master_branch
if gitflow_has_master_configured && ! flag force; then
- master_branch=$(git config --get gitflow.branch.master)
+ master_branch=$(git config --get $(gitflow_config).branch.master)
else
# Two cases are distinguished:
# 1. A fresh git repo (without any branches)
@@ -90,7 +90,7 @@ cmd_default() {
if [ "$branch_count" -eq 0 ]; then
echo "No branches exist yet. Base branches must be created now."
should_check_existence=NO
- default_suggestion=$(git config --get gitflow.branch.master || echo master)
+ default_suggestion=$(git config --get $(gitflow_config).branch.master || echo master)
else
echo
echo "Which branch should be used for bringing forth production releases?"
@@ -98,7 +98,7 @@ cmd_default() {
should_check_existence=YES
default_suggestion=
- for guess in $(git config --get gitflow.branch.master) \
+ for guess in $(git config --get $(gitflow_config).branch.master) \
'production' 'main' 'master'; do
if git_local_branch_exists "$guess"; then
default_suggestion="$guess"
@@ -122,13 +122,13 @@ cmd_default() {
fi
# store the name of the master branch
- git config gitflow.branch.master "$master_branch"
+ git config $(gitflow_config).branch.master "$master_branch"
fi
# add a develop branch if no such branch exists yet
local develop_branch
if gitflow_has_develop_configured && ! flag force; then
- develop_branch=$(git config --get gitflow.branch.develop)
+ develop_branch=$(git config --get $(gitflow_config).branch.develop)
else
# Again, the same two cases as with the master selection are
# considered (fresh repo or repo that contains branches)
@@ -137,7 +137,7 @@ cmd_default() {
branch_count=$(git_local_branches | grep -v "^${master_branch}\$" | wc -l)
if [ "$branch_count" -eq 0 ]; then
should_check_existence=NO
- default_suggestion=$(git config --get gitflow.branch.develop || echo develop)
+ default_suggestion=$(git config --get $(gitflow_config).branch.develop || echo develop)
else
echo
echo "Which branch should be used for integration of the \"next release\"?"
@@ -145,7 +145,7 @@ cmd_default() {
should_check_existence=YES
default_suggestion=
- for guess in $(git config --get gitflow.branch.develop) \
+ for guess in $(git config --get $(gitflow_config).branch.develop) \
'develop' 'int' 'integration' 'master'; do
if git_local_branch_exists "$guess"; then
default_suggestion="$guess"
@@ -173,7 +173,7 @@ cmd_default() {
fi
# store the name of the develop branch
- git config gitflow.branch.develop "$develop_branch"
+ git config $(gitflow_config).branch.develop "$develop_branch"
fi
# Creation of HEAD
@@ -214,11 +214,11 @@ cmd_default() {
# finally, ask the user for naming conventions (branch and tag prefixes)
if flag force || \
- ! git config --get gitflow.prefix.feature >/dev/null 2>&1 ||
- ! git config --get gitflow.prefix.release >/dev/null 2>&1 ||
- ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 ||
- ! git config --get gitflow.prefix.support >/dev/null 2>&1 ||
- ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then
+ ! git config --get $(gitflow_config).prefix.feature >/dev/null 2>&1 ||
+ ! git config --get $(gitflow_config).prefix.release >/dev/null 2>&1 ||
+ ! git config --get $(gitflow_config).prefix.hotfix >/dev/null 2>&1 ||
+ ! git config --get $(gitflow_config).prefix.support >/dev/null 2>&1 ||
+ ! git config --get $(gitflow_config).prefix.versiontag >/dev/null 2>&1; then
echo
echo "How to name your supporting branch prefixes?"
fi
@@ -226,8 +226,8 @@ cmd_default() {
local prefix
# Feature branches
- if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then
- default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
+ if ! git config --get $(gitflow_config).prefix.feature >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get $(gitflow_config).prefix.feature || echo feature/)
printf "Feature branches? [$default_suggestion] "
if noflag defaults; then
read answer
@@ -235,12 +235,12 @@ cmd_default() {
printf "\n"
fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.feature "$prefix"
+ git config $(gitflow_config).prefix.feature "$prefix"
fi
# Release branches
- if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then
- default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
+ if ! git config --get $(gitflow_config).prefix.release >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get $(gitflow_config).prefix.release || echo release/)
printf "Release branches? [$default_suggestion] "
if noflag defaults; then
read answer
@@ -248,13 +248,13 @@ cmd_default() {
printf "\n"
fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.release "$prefix"
+ git config $(gitflow_config).prefix.release "$prefix"
fi
# Hotfix branches
- if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then
- default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
+ if ! git config --get $(gitflow_config).prefix.hotfix >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get $(gitflow_config).prefix.hotfix || echo hotfix/)
printf "Hotfix branches? [$default_suggestion] "
if noflag defaults; then
read answer
@@ -262,13 +262,13 @@ cmd_default() {
printf "\n"
fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.hotfix "$prefix"
+ git config $(gitflow_config).prefix.hotfix "$prefix"
fi
# Support branches
- if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then
- default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
+ if ! git config --get $(gitflow_config).prefix.support >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get $(gitflow_config).prefix.support || echo support/)
printf "Support branches? [$default_suggestion] "
if noflag defaults; then
read answer
@@ -276,13 +276,13 @@ cmd_default() {
printf "\n"
fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.support "$prefix"
+ git config $(gitflow_config).prefix.support "$prefix"
fi
# Version tag prefix
- if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then
- default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
+ if ! git config --get $(gitflow_config).prefix.versiontag >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get $(gitflow_config).prefix.versiontag || echo "")
printf "Version tag prefix? [$default_suggestion] "
if noflag defaults; then
read answer
@@ -290,7 +290,7 @@ cmd_default() {
printf "\n"
fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.versiontag "$prefix"
+ git config $(gitflow_config).prefix.versiontag "$prefix"
fi
View
4 git-flow-release
@@ -39,8 +39,8 @@
require_git_repo
require_gitflow_initialized
gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.release)
+VERSION_PREFIX=$(eval "echo `git config --get $(gitflow_config).prefix.versiontag`")
+PREFIX=$(git config --get $(gitflow_config).prefix.release)
usage() {
echo "usage: git flow release [list] [-v]"
View
4 git-flow-support
@@ -39,8 +39,8 @@
require_git_repo
require_gitflow_initialized
gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.support)
+VERSION_PREFIX=$(eval "echo `git config --get $(gitflow_config).prefix.versiontag`")
+PREFIX=$(git config --get $(gitflow_config).prefix.support)
warn "note: The support subcommand is still very EXPERIMENTAL!"
warn "note: DO NOT use it in a production situation."
View
32 gitflow-common
@@ -152,39 +152,47 @@ git_is_branch_merged_into() {
# gitflow specific common functionality
#
+# assembles the configuration prefix
+# when called as git-flow, use gitflow, if called as git-flow-$something, use gitflow-$something.
+gitflow_config() {
+ local self=${GIT_FLOW_SELF:-$(basename $0)}
+ self="gitflow${self#git-flow}"
+ echo ${self}
+}
+
# check if this repo has been inited for gitflow
gitflow_has_master_configured() {
- local master=$(git config --get gitflow.branch.master)
+ local master=$(git config --get $(gitflow_config).branch.master)
[ "$master" != "" ] && git_local_branch_exists "$master"
}
gitflow_has_develop_configured() {
- local develop=$(git config --get gitflow.branch.develop)
+ local develop=$(git config --get $(gitflow_config).branch.develop)
[ "$develop" != "" ] && git_local_branch_exists "$develop"
}
gitflow_has_prefixes_configured() {
- git config --get gitflow.prefix.feature >/dev/null 2>&1 && \
- git config --get gitflow.prefix.release >/dev/null 2>&1 && \
- git config --get gitflow.prefix.hotfix >/dev/null 2>&1 && \
- git config --get gitflow.prefix.support >/dev/null 2>&1 && \
- git config --get gitflow.prefix.versiontag >/dev/null 2>&1
+ git config --get $(gitflow_config).prefix.feature >/dev/null 2>&1 && \
+ git config --get $(gitflow_config).prefix.release >/dev/null 2>&1 && \
+ git config --get $(gitflow_config).prefix.hotfix >/dev/null 2>&1 && \
+ git config --get $(gitflow_config).prefix.support >/dev/null 2>&1 && \
+ git config --get $(gitflow_config).prefix.versiontag >/dev/null 2>&1
}
gitflow_is_initialized() {
gitflow_has_master_configured && \
gitflow_has_develop_configured && \
- [ "$(git config --get gitflow.branch.master)" != \
- "$(git config --get gitflow.branch.develop)" ] && \
+ [ "$(git config --get $(gitflow_config).branch.master)" != \
+ "$(git config --get $(gitflow_config).branch.develop)" ] && \
gitflow_has_prefixes_configured
}
# loading settings that can be overridden using git config
gitflow_load_settings() {
export DOT_GIT_DIR=$(git rev-parse --git-dir >/dev/null 2>&1)
- export MASTER_BRANCH=$(git config --get gitflow.branch.master)
- export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop)
- export ORIGIN=$(git config --get gitflow.origin || echo origin)
+ export MASTER_BRANCH=$(git config --get $(gitflow_config).branch.master)
+ export DEVELOP_BRANCH=$(git config --get $(gitflow_config).branch.develop)
+ export ORIGIN=$(git config --get $(gitflow_config).origin || echo origin)
}
#
Something went wrong with that request. Please try again.