From 4ed58553175dd8d4491ba4c7f56b1c2399f41d69 Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Tue, 12 Mar 2013 23:23:40 -0300 Subject: [PATCH 1/3] Add 'remote' argument to heroku Also add the shorter -a switch to the app argument --- src/_heroku | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_heroku b/src/_heroku index 820cfe1..6794299 100644 --- a/src/_heroku +++ b/src/_heroku @@ -162,7 +162,8 @@ case "$words[1]" in _arguments \ $_command_args \ - '(--app)--app[the app name]' \ + '(-a|--app)'{-a,--app}'[the app name]' \ + '(-r|--remote)'{-r,--remote}'[the git remote name]' \ && return 0 # Local Variables: From d5674edf4492408418ea240fc5056449fa9d792d Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Wed, 13 Mar 2013 13:47:23 -0300 Subject: [PATCH 2/3] Add remote argument completions This was copied from _git-flow --- src/_heroku | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/_heroku b/src/_heroku index 6794299..b9a8967 100644 --- a/src/_heroku +++ b/src/_heroku @@ -163,9 +163,40 @@ case "$words[1]" in _arguments \ $_command_args \ '(-a|--app)'{-a,--app}'[the app name]' \ - '(-r|--remote)'{-r,--remote}'[the git remote name]' \ + '(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \ && return 0 +__git_remotes () { + local expl gitdir remotes + + gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return + + remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) + __git_command_successful || return + + # TODO: Should combine the two instead of either or. + if (( $#remotes > 0 )); then + _wanted remotes expl remote compadd $* - $remotes + else + _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" + fi +} + +__git_command_successful () { + if (( ${#pipestatus:#0} > 0 )); then + _message 'not a git repository' + return 1 + fi + return 0 +} + +case $state in + (remotes) + __git_remotes && return 0 + ;; +esac + # Local Variables: # mode: Shell-Script # sh-indentation: 2 From 779b6020b6559f1c3bf7213025ed88a29d9e4f38 Mon Sep 17 00:00:00 2001 From: Paulo L F Casaretto Date: Thu, 11 Apr 2013 14:18:51 -0300 Subject: [PATCH 3/3] Namespace git commands under heroku --- src/_heroku | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_heroku b/src/_heroku index b9a8967..853ea9c 100644 --- a/src/_heroku +++ b/src/_heroku @@ -166,14 +166,14 @@ _arguments \ '(-r|--remote)'{-r,--remote}'[the git remote name]:remote:->remotes' \ && return 0 -__git_remotes () { +__heroku_git_remotes () { local expl gitdir remotes gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) - __git_command_successful || return + __heroku_git_command_successful || return remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) - __git_command_successful || return + __heroku_git_command_successful || return # TODO: Should combine the two instead of either or. if (( $#remotes > 0 )); then @@ -183,7 +183,7 @@ __git_remotes () { fi } -__git_command_successful () { +__heroku_git_command_successful () { if (( ${#pipestatus:#0} > 0 )); then _message 'not a git repository' return 1 @@ -193,7 +193,7 @@ __git_command_successful () { case $state in (remotes) - __git_remotes && return 0 + __heroku_git_remotes && return 0 ;; esac