From d3b40075948ec008480256977e24c0db8114acee Mon Sep 17 00:00:00 2001
From: Bruno Pinto <brunoferreirapinto@gmail.com>
Date: Sun, 31 May 2015 14:24:22 +0100
Subject: [PATCH] handling failures on git clone

---
 plugins/omf/omf.packages.fish         | 12 +++++++++++-
 plugins/omf/omf.packages.install.fish | 18 ++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/plugins/omf/omf.packages.fish b/plugins/omf/omf.packages.fish
index 19d067e..97e850b 100644
--- a/plugins/omf/omf.packages.fish
+++ b/plugins/omf/omf.packages.fish
@@ -60,7 +60,17 @@ function omf.packages.report.updating -e omf_package_updating
   omf.log -n white "Updating $argv... "
 end
 
+function omf.packages.report.failed -e omf_package_install_failed -e omf_package_update_failed
+  omf.log red "✖"
+
+  set_color yellow
+  cat /tmp/oh-my-fish.clone.log
+  set_color normal
+
+  set __omf_packages_modified (expr $__omf_packages_modified + 1)
+end
+
 function omf.packages.report.finished -e omf_package_installed -e omf_package_updated
-  omf.log green  "√"
+  omf.log green "✔"
   set __omf_packages_modified (expr $__omf_packages_modified + 1)
 end
diff --git a/plugins/omf/omf.packages.install.fish b/plugins/omf/omf.packages.install.fish
index 5aa9604..51e90b7 100644
--- a/plugins/omf/omf.packages.install.fish
+++ b/plugins/omf/omf.packages.install.fish
@@ -15,16 +15,26 @@ function omf.packages.install --argument-names type name -d "Install a plugin or
         # Plugin is already installed. Skipping.
       else
         emit omf_package_installing $name
-        git clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name ^ /dev/null
-        emit omf_package_installed $name
+        git clone --quiet "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name ^ /tmp/oh-my-fish.clone.log
+
+        if [ $status -eq 0 ]
+          emit omf_package_installed $name
+        else
+          emit omf_package_install_failed $name
+        end
       end
     case '--theme'
       if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ]
         # Theme is already installed. Skipping.
       else
         emit omf_package_installing $name
-        git clone "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name ^ /dev/null
-        emit omf_package_installed $name
+        git clone --quiet "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name ^ /tmp/oh-my-fish.clone.log
+
+        if [ $status -eq 0 ]
+          emit omf_package_installed $name
+        else
+          emit omf_package_install_failed $name
+        end
       end
     case '*'
       omf.log red 'Unknown option'
-- 
GitLab