1
0
Fork 0
mirror of synced 2024-12-13 19:05:45 -05:00

Now outputs git pull status when updating plugins.

Removed pipe to /dev/null for $(pull_changes $plugin).

Part of #76.

At least for now, I've formatted the output to look like the below paste. This
 shows a failed, no-op success, and pull success:

===================================================

Updating all plugins!

Updating "tpm"
     | There is no tracking information for the current branch.
     | Please specify which branch you want to merge with.
     | See git-pull(1) for details.
     |
     |     git pull <remote> <branch>
     |
     | If you wish to set tracking information for this branch you can do so with:
     |
     |     git branch --set-upstream-to=<remote>/<branch> nhdaly_update_output
  "tpm" update fail

Updating "tmux-sensible"
     | Already up-to-date.
  "tmux-sensible" update success

Updating "tmux-scroll-copy-mode"
     | Updating 1ee5602..5e4c864
     | Fast-forward
     |  README.md             | 5 +++--
     |  scroll_copy_mode.tmux | 8 +++++---
     |  2 files changed, 8 insertions(+), 5 deletions(-)
  "tmux-scroll-copy-mode" update success
This commit is contained in:
Nathan Daly 2016-08-21 12:47:45 -05:00
parent b4c89884e0
commit 3a39926b86

View file

@ -25,12 +25,28 @@ pull_changes() {
GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
} }
print_update_status() {
# Indent and format the output from the update command.
local plugin="$1"
local update_output=$(echo "$2" | awk '{print " | "$0}')
local update_status=$3
if [ $update_status == "0" ]; then
echo_ok "$update_output\n \"$plugin\" update success"
echo_ok
else
echo_err "$update_output\n \"$plugin\" update fail"
echo_err
fi
}
update() { update() {
local plugin="$1" local plugin="$1"
echo_ok "Updating \"$plugin\"" echo_ok "Updating \"$plugin\""
$(pull_changes "$plugin" > /dev/null 2>&1) && # Note, this cannot be a local variable, since that seems to supress the $? from being set.
echo_ok " \"$plugin\" update success" || update_output=$(pull_changes "$plugin" 2>&1);
echo_err " \"$plugin\" update fail" local update_status="$?"
$(print_update_status "$plugin" "$update_output" "$update_status")
} }
update_all() { update_all() {