From 4374e1155dc1ef048928051e0c8546d0c8ba6616 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Thu, 29 Sep 2016 11:46:56 -0400 Subject: [PATCH] Update submodules, clean up the update, specify the need for coretutils (for the timeout command), and allow the use of gtimeout in the update script on OSX --- README.md | 1 + update | 34 ++++++++++++++++++++++++++++++++-- vim/bundle/neocomplete.vim | 2 +- vim/bundle/vim-signify | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 697b079..56fc026 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A theme, config and collection of plugins for Vim. * **Vim**: The latest [vim](http://www.vim.org) should be installed to use this distribution (versions 7.3 and below aren't tested or guaranteed to work). * **Bash**: Required by the _update_ and _gentags_ scripts. +* **Coreutils**: Required by the _update_ script. * **Git**: Required by the _update_ script and git-related plugins. * **Python**: Required by the _gundo_ and _MatchTagAlways_ plugins. diff --git a/update b/update index 87886a6..d451bd6 100755 --- a/update +++ b/update @@ -10,6 +10,7 @@ script_name="${0//*\/}" script_home="${0%$script_name}" + if [[ -z "$script_home" ]]; then script_home="$PWD" else @@ -17,6 +18,7 @@ else script_home="$PWD" popd >/dev/null fi + repo_version="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")" error_log='update-errors.log' @@ -36,10 +38,12 @@ error_log='update-errors.log' function error { printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! ERROR: $c_reset$cfg_red_bold $2 " >&2 printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! COMMAND: $c_reset ${cfg_white_bold}=> $1$c_reset" >&2 + [[ -n "$3" ]] \ && printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! OUTPUT: $c_reset$cfg_white_bold $3" >&2 printf '%s\n%s\n%s\n' "DATE: @ $(date)" "ERROR: $2" "COMMAND: $1" >> "$script_home/$error_log" + [[ -n "$3" ]] \ && printf '%s\n' "OUTPUT: $3" >> "$script_home/$error_log" @@ -62,6 +66,15 @@ function show_help { } ### SETUP +if type -P timeout >/dev/null; then + timeout_command=timeout +elif type -P gtimeout >/dev/null; then + timeout_command=gtimeout +else + error 'type -P timeout' 'The timeout command could not be found (install coreutils)' + exit 1 +fi + cd "$script_home" || exit # delete old error log if it exists @@ -95,6 +108,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset" [[ -d 'vim/bundle.user' ]] || { printf '\n%s' "$cbg_blue >> Creating user plugin directory:$c_reset" process_status="$(install -d 'vim/bundle.user' 2>&1)" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -107,6 +121,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset" [[ -e 'vim/vimrc.user' ]] || { printf '\n%s' "$cbg_blue >> Creating user config file:$c_reset" process_status="$(touch 'vim/vimrc.user' 2>&1)" + if (( ! $? )); then { printf '%s\n%s\n\n' '"Autostart Filer in empty buffers: (*1:filer loads in new empty buffers | 0:filer must be triggered)' '"let g:autostartfiler=1' @@ -117,6 +132,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset" printf '%s\n%s\n\n' '"Enable Powerline fonts: (1:expect powerline font | *0:expect regular font)' '"let g:powerlinefonts=0 "(set powerline font for gvim and terminal when enabled)' printf '%s\n%s\n' '"GVim font selection: (Escaping spaces and use powerline if appropriate)' '"set guifont=Monospace\ 12' } >> vim/vimrc.user + if [[ -e 'vim/vimrc.user' ]]; then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -131,6 +147,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset" ### REPO UPDATE printf '\n%s' "$cbg_blue >> Updating darkcloud-vimconfig:$c_reset" process_status="$(git pull origin master 2>&1)" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -143,6 +160,7 @@ fi printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset" process_status="$(git submodule sync 2>&1)" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -154,8 +172,10 @@ fi printf '%s' "$cbg_blue $c_reset$cbg_yellow + Fetching updates:$c_reset" git submodule foreach git reset --hard >/dev/null 2>&1 process_status="$(git submodule foreach git fetch --all 2>&1)" + if (( ! $? )); then process_status=$(git submodule update --init --recursive 2>&1) + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -170,6 +190,7 @@ fi # run 'git checkout origin/master' on each submodule printf '%s' "$cbg_blue $c_reset$cbg_yellow + Checkout updates:$c_reset" process_status="$(git submodule foreach git checkout -f origin/master 2>&1)" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -181,6 +202,7 @@ fi printf '\n%s\n' "$cbg_blue >> Clean plugin directories >> $c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Remove untracked files:$c_reset" process_status="$(git submodule foreach git clean -dxf 2>&1)" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -192,12 +214,15 @@ fi for plugin in vim/bundle/*; do [[ -f "$plugin/.git" ]] && { plugin_dirname="${plugin/*\/}" + grep 'path = ' .gitmodules | egrep -o '[^\/]*$' | egrep -q "$plugin_dirname$" || { [[ -z "$first_found" ]] && { first_found=1 printf '%s\n' "$cbg_blue $c_reset$cbg_yellow + Removing old plugins: $c_reset" } + process_status="$(rm -rf "${plugin:?}")" + if (( ! $? )); then printf '%s\n' "$cbg_blue $c_reset$cbg_yellow = $cfg_white_bold$plugin$c_reset" else @@ -207,6 +232,7 @@ fi } } done + printf '\n' } @@ -214,11 +240,13 @@ fi [[ -d vim/bundle.user ]] && find vim/bundle.user -mindepth 3 -maxdepth 3 -name config | grep -q '.git/config' && { printf '%s\n' "$cbg_blue >> Updating user plugins >> $c_reset" pushd 'vim/bundle.user' >/dev/null + for plugin in *; do [[ -d "$plugin/.git" ]] && { pushd "$plugin" >/dev/null printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating 'vim/bundle.user/$plugin':$c_reset" process_status="$(git pull origin master 2>&1)" + if (( ! $? )); then if ! grep -q "Already up-to-date" <<< "$process_status"; then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" @@ -228,9 +256,11 @@ fi else error 'git pull origin master' "Failed pulling changes for $plugin" "$process_status" fi + popd >/dev/null } done + popd >/dev/null printf '\n' } @@ -238,7 +268,8 @@ fi ### GENERATE PLUGIN HELP [[ $(type -P vim) ]] && { printf '%s' "$cbg_blue >> Generating plugin help:$c_reset" - timeout --preserve-status --foreground 1m vim -u "./vimrc" -c "Helptags|qa!" + $timeout_command --preserve-status --foreground 1m vim -u "./vimrc" -c "Helptags|qa!" + if (( ! $? )); then printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" else @@ -250,4 +281,3 @@ fi ### FINISH printf '\n%s\n\n' "$cbg_black ~~~ Update Complete ~~~ $c_reset" - diff --git a/vim/bundle/neocomplete.vim b/vim/bundle/neocomplete.vim index 75b2ea0..16d6503 160000 --- a/vim/bundle/neocomplete.vim +++ b/vim/bundle/neocomplete.vim @@ -1 +1 @@ -Subproject commit 75b2ea052310bf4615c739808ba9de03f8cdc113 +Subproject commit 16d650348538f780d282863ecbdcc45319d36522 diff --git a/vim/bundle/vim-signify b/vim/bundle/vim-signify index 472668f..faf7a03 160000 --- a/vim/bundle/vim-signify +++ b/vim/bundle/vim-signify @@ -1 +1 @@ -Subproject commit 472668fbd286c8f8f3db0024a02056d4c25524b1 +Subproject commit faf7a0307180ec10418fa0eae85e68b526eed267