2c660c16ad818d4e1f001e392f7e82c7c02cbbc6

Author
Daniel Hahler <git@thequod.de>
Committer
Daniel Hahler <git@thequod.de>
Date

Message

Only alias git=hub if `hub --version` works.

`hub` is crashing for me on a old CentOS setup with
"undefined method `shelljoin'".

On first use of the `git` function it is now checked if
`hub --version` returns successfully.

Diff

 1diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh
 2index 9b0d54602fcfe03edc072921cbe2134908250286..197e86a48743419f79cceb8f4d4ebdafca0a5972 100644
 3--- a/plugins/github/github.plugin.zsh
 4+++ b/plugins/github/github.plugin.zsh
 5@@ -1,7 +1,17 @@
 6 # Setup hub function for git, if it is available; http://github.com/defunkt/hub
 7 if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
 8     # eval `hub alias -s zsh`
 9-    function git(){hub "$@"}
10+    function git(){
11+        if ! (( $+_has_working_hub  )); then
12+            hub --version &> /dev/null
13+            _has_working_hub=$(($? == 0))
14+        fi
15+        if (( $_has_working_hub )) ; then
16+            hub "$@"
17+        else
18+            command git "$@"
19+        fi
20+    }
21 fi
22 
23 # Functions #################################################################