From b93b203b9eb754ea5b3e99b8e3836f902404e700 Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Wed, 21 Jul 2021 12:58:23 +0100 Subject: [PATCH] Implemented a new new name filters --- git-flow-bugfix | 8 ++++++++ git-flow-feature | 8 ++++++++ gitflow-common | 4 ++-- hooks/filter-flow-bugfix-start-name | 22 ++++++++++++++++++++++ hooks/filter-flow-feature-start-name | 22 ++++++++++++++++++++++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 hooks/filter-flow-bugfix-start-name create mode 100755 hooks/filter-flow-feature-start-name diff --git a/git-flow-bugfix b/git-flow-bugfix index e27f05cf..c6388f0b 100644 --- a/git-flow-bugfix +++ b/git-flow-bugfix @@ -197,6 +197,14 @@ F,[no]fetch Fetch from origin before performing local operation eval set -- "${FLAGS_ARGV}" base=${2:-$DEVELOP_BRANCH} + # Run filter on the name + NAME=$(run_filter_hook bugfix-start-name $NAME) + if [ $? -eq 127 ]; then + die $NAME + fi + + BRANCH="$PREFIX$NAME" + require_base_is_local_branch "$base" gitflow_require_name_arg diff --git a/git-flow-feature b/git-flow-feature index 0feeb4e6..7ab006af 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -197,6 +197,14 @@ F,[no]fetch Fetch from origin before performing local operation eval set -- "${FLAGS_ARGV}" base=${2:-$DEVELOP_BRANCH} + # Run filter on the name + NAME=$(run_filter_hook feature-start-name $NAME) + if [ $? -eq 127 ]; then + die $NAME + fi + + BRANCH="$PREFIX$NAME" + require_base_is_local_branch "$base" gitflow_require_name_arg diff --git a/gitflow-common b/gitflow-common index 0ad52648..768e15e1 100644 --- a/gitflow-common +++ b/gitflow-common @@ -749,12 +749,12 @@ run_filter_hook() { shift scriptfile="${HOOKS_DIR}/filter-flow-${command}" if [ -x "$scriptfile" ]; then - return=`$scriptfile "$@"` + return=`$scriptfile "$*"` if [ $? -eq 127 ]; then echo "$return" exit 127 fi - echo $return + echo $return else echo "$@" fi diff --git a/hooks/filter-flow-bugfix-start-name b/hooks/filter-flow-bugfix-start-name new file mode 100755 index 00000000..4e13b045 --- /dev/null +++ b/hooks/filter-flow-bugfix-start-name @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Runs during git flow feature start +# +# Positional arguments: +# $1 Name +# +# Return NAME - When NAME is returned empty, git-flow will stop as the +# Name is necessary +# +# The following variables are available as they are exported by git-flow: +# +# MASTER_BRANCH - The branch defined as Master +# DEVELOP_BRANCH - The branch defined as Develop +# +NAME=$1 + +# Implement your script here. + +# Return the NAME +echo ${NAME} +exit 0 diff --git a/hooks/filter-flow-feature-start-name b/hooks/filter-flow-feature-start-name new file mode 100755 index 00000000..eff0ec69 --- /dev/null +++ b/hooks/filter-flow-feature-start-name @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Runs during git flow feature start +# +# Positional arguments: +# $1 Name +# +# Return NAME - When NAME is returned empty, git-flow will stop as the +# name is necessary +# +# The following variables are available as they are exported by git-flow: +# +# MASTER_BRANCH - The branch defined as Master +# DEVELOP_BRANCH - The branch defined as Develop +# +NAME=$1 + +# Implement your script here. + +# Return the NAME +echo ${NAME} +exit 0