80257bdf214fa49cce5a79062ecb53053cbfabc8

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #717 from blueyed/github-plugin-working-hub

github plugin: only alias git=hub if `hub --version` works.

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 #################################################################