Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implement version filter #186

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions git-flow-hotfix
Expand Up @@ -157,6 +157,10 @@ cmd_start() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
parse_args "$@" parse_args "$@"
BASE=${2:-$MASTER_BRANCH} BASE=${2:-$MASTER_BRANCH}
# Run filter on the version
VERSION=`run_filter_hook hotfix-start-version $VERSION`
# As VERSION might have changed reset BRANCH with new VERSION
BRANCH=$PREFIX$VERSION
require_version_arg require_version_arg
require_base_is_on_master require_base_is_on_master
require_no_existing_hotfix_branches require_no_existing_hotfix_branches
Expand Down
4 changes: 4 additions & 0 deletions git-flow-release
Expand Up @@ -153,6 +153,10 @@ cmd_start() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
parse_args "$@" parse_args "$@"
BASE=${2:-$DEVELOP_BRANCH} BASE=${2:-$DEVELOP_BRANCH}
# Run filter on the version
VERSION=`run_filter_hook release-start-version $VERSION`
# As VERSION might have changed reset BRANCH with new VERSION
BRANCH=$PREFIX$VERSION
require_version_arg require_version_arg
require_base_is_on_develop require_base_is_on_develop
require_no_existing_release_branches require_no_existing_release_branches
Expand Down
22 changes: 22 additions & 0 deletions gitflow-common
Expand Up @@ -186,6 +186,7 @@ gitflow_is_initialized() {
# loading settings that can be overridden using git config # loading settings that can be overridden using git config
gitflow_load_settings() { gitflow_load_settings() {
export DOT_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null) export DOT_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
export HOOKS_DIR="$DOT_GIT_DIR"/hooks
export MASTER_BRANCH=$(git config --get gitflow.branch.master) export MASTER_BRANCH=$(git config --get gitflow.branch.master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop) export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin) export ORIGIN=$(git config --get gitflow.origin || echo origin)
Expand Down Expand Up @@ -316,3 +317,24 @@ require_branches_equal() {
fi fi
fi fi
} }

#
# run_filter_hook
#
# Looks for a Git hook script called as defined by the first variable
#
# filter-flow-command
#
# If such a hook script exists and is executable, it is called with the given
# positional arguments.
#
run_filter_hook() {
local command=$1
shift
local scriptfile="${HOOKS_DIR}/filter-flow-${command}"
if [ -x $scriptfile ]; then
echo `$scriptfile "$@"`
else
echo "$@"
fi
}
17 changes: 17 additions & 0 deletions hooks/filter-flow-hotfix-start-version
@@ -0,0 +1,17 @@
#!/bin/sh
#
# Runs during git flow hotfix start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
VERSION=$1

# Implement your script here.

# Return the VERSION
echo ${VERSION}
exit 0
17 changes: 17 additions & 0 deletions hooks/filter-flow-release-start-version
@@ -0,0 +1,17 @@
#!/bin/sh
#
# Runs during git flow release start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
VERSION=$1

# Implement your script here.

# Return the VERSION
echo ${VERSION}
exit 0