Skip to content
Browse files

Merge branch 'release/0.4.0'

  • Loading branch information...
2 parents b2447fe + ae24ff3 commit ba64bb2c1bd500197d74b22ca22287b9386ba8fa @bobthecow committed Oct 23, 2010
Showing with 62 additions and 42 deletions.
  1. +2 −2 README.markdown
  2. +60 −40 git-flow-completion.bash
View
4 README.markdown
@@ -5,9 +5,9 @@ Bash and Zsh completion support for [git-flow](http://github.com/nvie/gitflow)
The contained completion routines provide support for completing:
- * git-flow init, feature, hotfix and release
+ * git-flow init and version
* feature, hotfix and release branches
- * remote feature branch names (for `git-flow feature track`)
+ * remote feature, hotfix and release branch names
Installation for Bash
View
100 git-flow-completion.bash
@@ -9,7 +9,7 @@
#
# * git-flow init and version
# * feature, hotfix and release branches
-# * remote feature branch names (for `git-flow feature track`)
+# * remote feature, hotfix and release branch names
#
#
# Installation
@@ -47,14 +47,18 @@
_git_flow ()
{
- local subcommands="init feature release hotfix"
+ local subcommands="init feature release hotfix help version"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
fi
case "$subcommand" in
+ init)
+ __git_flow_init
+ return
+ ;;
feature)
__git_flow_feature
return
@@ -73,9 +77,19 @@ _git_flow ()
esac
}
+__git_flow_init ()
+{
+ local subcommands="help"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+}
+
__git_flow_feature ()
{
- local subcommands="list start finish publish track diff rebase checkout pull"
+ local subcommands="list start finish publish track diff rebase checkout pull help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
@@ -88,15 +102,15 @@ __git_flow_feature ()
return
;;
checkout|finish|diff|rebase)
- __gitcomp "$(__git_flow_list_features)"
+ __gitcomp "$(__git_flow_list_branches 'feature')"
return
;;
publish)
- __gitcomp "$(comm -23 <(__git_flow_list_features) <(__git_flow_list_remote_features))"
+ __gitcomp "$(comm -23 <(__git_flow_list_branches 'feature') <(__git_flow_list_remote_branches 'feature'))"
return
;;
track)
- __gitcomp "$(__git_flow_list_remote_features)"
+ __gitcomp "$(__git_flow_list_remote_branches 'feature')"
return
;;
*)
@@ -105,26 +119,9 @@ __git_flow_feature ()
esac
}
-__git_flow_list_features ()
-{
- local prefix="$(__git_flow_feature_prefix)"
- git branch 2> /dev/null | tr -d ' |*' | grep "^$prefix" | sed s,^$prefix,,
-}
-
-__git_flow_list_remote_features ()
-{
- local prefix="$(__git_flow_feature_prefix)"
- git branch -r 2> /dev/null | sed "s/^ *//g" | grep "^origin/$prefix" | sed s,^origin/$prefix,,
-}
-
-__git_flow_feature_prefix ()
-{
- git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
-}
-
__git_flow_release ()
{
- local subcommands="list start finish"
+ local subcommands="list start finish track publish help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
@@ -133,7 +130,15 @@ __git_flow_release ()
case "$subcommand" in
finish)
- __gitcomp "$(__git_flow_list_releases)"
+ __gitcomp "$(__git_flow_list_branches 'release')"
+ return
+ ;;
+ publish)
+ __gitcomp "$(comm -23 <(__git_flow_list_branches 'release') <(__git_flow_list_remote_branches 'release'))"
+ return
+ ;;
+ track)
+ __gitcomp "$(__git_flow_list_remote_branches 'release')"
return
;;
*)
@@ -143,20 +148,9 @@ __git_flow_release ()
}
-__git_flow_list_releases ()
-{
- local prefix="$(__git_flow_release_prefix)"
- git branch 2> /dev/null | tr -d ' |*' | grep "^$prefix" | sed s,^$prefix,,
-}
-
-__git_flow_release_prefix ()
-{
- git config gitflow.prefix.release 2> /dev/null || echo "release/"
-}
-
__git_flow_hotfix ()
{
- local subcommands="list start finish"
+ local subcommands="list start finish track publish help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
@@ -165,7 +159,15 @@ __git_flow_hotfix ()
case "$subcommand" in
finish)
- __gitcomp "$(__git_flow_list_hotfixes)"
+ __gitcomp "$(__git_flow_list_branches 'hotfix')"
+ return
+ ;;
+ publish)
+ __gitcomp "$(comm -23 <(__git_flow_list_branches 'hotfix') <(__git_flow_list_remote_branches 'hotfix'))"
+ return
+ ;;
+ track)
+ __gitcomp "$(__git_flow_list_remote_branches 'hotfix')"
return
;;
*)
@@ -174,9 +176,27 @@ __git_flow_hotfix ()
esac
}
-__git_flow_list_hotfixes ()
+__git_flow_prefix ()
+{
+ case "$1" in
+ feature|release|hotfix)
+ git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
+ return
+ ;;
+ esac
+}
+
+__git_flow_list_branches ()
+{
+ local prefix="$(__git_flow_prefix $1)"
+ git branch 2> /dev/null | tr -d ' |*' | grep "^$prefix" | sed s,^$prefix,,
+}
+
+__git_flow_list_remote_branches ()
{
- git flow hotfix list 2> /dev/null
+ local prefix="$(__git_flow_prefix $1)"
+ local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
+ git branch -r 2> /dev/null | sed "s/^ *//g" | grep "^$origin/$prefix" | sed s,^$origin/$prefix,,
}
# alias __git_find_on_cmdline for backwards compatibility

0 comments on commit ba64bb2

Please sign in to comment.
Something went wrong with that request. Please try again.