Refactored the subcommand invocation logic to form a more hierarchical structure and a cleaner design.
diff --git a/git-flow-hotfix b/git-flow-hotfix
index 47b2bd7..d921762 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -13,8 +13,9 @@
#
usage() {
- echo "usage: git flow start hotfix <version> [<base>]"
- echo " git flow finish hotfix <version> [<base>]"
+ echo "usage: git flow hotfix"
+ echo " git flow hotfix start <version> [<base>]"
+ echo " git flow hotfix finish <version> [<base>]"
# TODO
#echo ""
#echo "options:"
@@ -39,6 +40,17 @@
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."
+ exit 0
+ fi
+ echo "$HOTFIX_BRANCHES" | sed "s?^$PREFIX??g"
+}
+
cmd_help() {
usage
exit 0