mirror of
https://github.com/prurigro/darkcloud-vimconfig.git
synced 2024-11-21 14:32:32 -05:00
Moving vim-signify back upstream now that my fix has been pulled, and
I completely revamped the update script to better handle changing submodules around, to look way better at the same time as more clearly outlining what's going on (and whether anything's going wrong), and to have logging capabilities to help see why things fail when they do.
This commit is contained in:
parent
7c6ff700aa
commit
0d0ffb51ca
3 changed files with 103 additions and 27 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -69,7 +69,7 @@
|
|||
url = https://github.com/gcmt/breeze.vim.git
|
||||
[submodule "vim/bundle/vim-signify"]
|
||||
path = vim/bundle/vim-signify
|
||||
url = https://github.com/prurigro/vim-signify
|
||||
url = https://github.com/mhinz/vim-signify
|
||||
[submodule "vim/bundle/vim-repeat"]
|
||||
path = vim/bundle/vim-repeat
|
||||
url = https://github.com/tpope/vim-repeat.git
|
||||
|
|
126
update
126
update
|
@ -1,12 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# work from the base directory of the repository
|
||||
# change to the base directory
|
||||
cd "${0%/*}"
|
||||
|
||||
# create the user vimrc file in the directory if it doesn't already exist
|
||||
[[ ! -d vim ]] && install -d vim
|
||||
# define an error function to both output and record errors
|
||||
ERRORLOG="update-errors.log"
|
||||
|
||||
function error() {
|
||||
echo -e "\e[44m \e[0m\e[01;41m ! ERROR: \e[0m\e[1;31m ${2} "
|
||||
echo -e "\e[44m \e[0m\e[01;41m ! \e[0m \e[1;37m=> ${1}\e[0m"
|
||||
[[ -n "$3" ]] && echo -e "\e[44m \e[0m\e[01;41m ! \e[0m\e[1;37m ${3}"
|
||||
|
||||
echo "${1} @ $(date)" >> "$ERRORLOG"
|
||||
echo " ! Error: ${2}" >> "$ERRORLOG"
|
||||
[[ -n "$3" ]] && echo " ! ${3}" >> "$ERRORLOG"
|
||||
echo >> "$ERRORLOG"
|
||||
}
|
||||
|
||||
# initialize the errorlog file for this session
|
||||
echo > "$ERRORLOG"
|
||||
|
||||
# create vim/vimrc.user and vim/bundle.user if they don't already exist
|
||||
[[ ! -d vim/bundle.user ]] && install -d vim/bundle.user
|
||||
if [ ! -e vim/vimrc.user ]; then
|
||||
echo "Creating user configuration file 'vim/vimrc.user'..."
|
||||
echo -e "\n\e[40m ~~~ DarkCloud Vimconfig Setup ~~~ \e[0m"
|
||||
echo -e "\n\e[44m >> Create User Config: 'vim/vimrc.user' \e[0m"
|
||||
if [ -w vim ]; then
|
||||
echo -e '"Disable Linebreaks: (*1:force disabled globally | 0: disabled by default)\n"let g:disablelinebreaks=0\n' >> vim/vimrc.user
|
||||
echo -e '"Autostart Filer: (*1:filer loads in new empty buffers | 0: filer must be triggered)\n"let g:autostartfiler=0\n' >> vim/vimrc.user
|
||||
|
@ -15,41 +33,98 @@ if [ ! -e vim/vimrc.user ]; then
|
|||
echo -e '"Powerline Fonts: (1:enabled | *0:disabled)\n"let g:powerlinefonts=1 "(set powerline font for gvim and terminal when enabled)\n' >> vim/vimrc.user
|
||||
echo -e '"GVim Font Selection: (Escaping spaces and use powerline if appropriate)\nset guifont=Monospace\ 12' >> vim/vimrc.user
|
||||
fi
|
||||
echo
|
||||
else
|
||||
echo -e "\n\e[40m ~~~ DarkCloud Vimconfig Update Tool ~~~ \e[0m"
|
||||
fi
|
||||
echo
|
||||
|
||||
# update darkcloud-vimconfig
|
||||
echo -n -e "\e[44m >> Updating Repository: \e[0m"
|
||||
GIT_STATUS=$(git pull origin master 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "\e[0;32m SUCCESS! \e[0m"
|
||||
else
|
||||
echo -e "\e[1;31m FAIL! \e[0m"
|
||||
error "git pull origin master" "Git failed to sync the repo" "Git output: ${GIT_STATUS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating darkcloud-vimconfig..."
|
||||
git pull origin
|
||||
git submodule sync
|
||||
# setup and sync the submodules
|
||||
echo -e "\n\e[44m >> Updating Plugin Submodules >> \e[0m"
|
||||
echo -n -e "\e[44m \e[0m\e[43m + Updating Plugin URLs: \e[0m"
|
||||
GIT_STATUS=$(git submodule sync 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "\e[0;32m SUCCESS! \e[0m"
|
||||
else
|
||||
echo -e "\e[1;31m FAIL! \e[0m"
|
||||
error "git submodule sync" "Git failed to sync the submodules" "Git output: ${GIT_STATUS}"
|
||||
fi
|
||||
|
||||
echo -e "\nUpdating plugin submodules..."
|
||||
git submodule update --init --recursive
|
||||
echo -n -e "\e[44m \e[0m\e[43m + Fetching Updates: \e[0m"
|
||||
GIT_STATUS=$(git submodule foreach git fetch --all 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
GIT_STATUS=$(git submodule update --init --recursive 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "\e[0;32m SUCCESS! \e[0m"
|
||||
else
|
||||
echo -e "\e[1;31m FAIL! \e[0m"
|
||||
error "git submodule update --init --recursive" "Git failed to update the submodules" "Git output: ${GIT_STATUS}"
|
||||
fi
|
||||
else
|
||||
echo -e "\e[1;31m FAIL! \e[0m"
|
||||
error "git submodule foreach git fetch --all" "Git failed to fetch the submodules from their respective remotes" "Git output: ${GIT_STATUS}"
|
||||
fi
|
||||
|
||||
# delete submodules in vim/bundle that were removed up stream
|
||||
echo -e "\nConfiguring plugin submodules..."
|
||||
echo -n -e "\e[44m \e[0m\e[43m + Checkout Origin/Master: \e[0m"
|
||||
GIT_STATUS=$(git submodule foreach git checkout -f origin/master 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "\e[0;32m SUCCESS! \e[0m"
|
||||
else
|
||||
echo -e "\e[1;31m FAIL! \e[0m"
|
||||
error "git submodule foreach git checkout -f origin/master" "Git failed to checkout the submodules into origin/master" "Git output: ${GIT_STATUS}"
|
||||
fi
|
||||
|
||||
# clean plugin directories and remove plugins no longer in the repo
|
||||
echo -e "\n\e[44m >> Cleaning Plugin Directories >> \e[0m"
|
||||
echo -n -e "\e[44m \e[0m\e[43m + Removing Untracked Files: \e[0m"
|
||||
git submodule foreach git clean -dxf > /dev/null 2>&1 && echo -e "\e[0;32m SUCCESS! \e[0m" || echo -e "\e[1;31m FAIL! \e[0m"
|
||||
[[ -f .gitmodules ]] && for each in vim/bundle/*; do
|
||||
if [ -d "$each" ]; then
|
||||
if [ -f "${each}/.git" ]; then
|
||||
FILE=$(echo $each | grep -o -e "[^\/]*$")
|
||||
[[ `cat .gitmodules | grep "path = " | grep -o -e "[^\/]*$" | grep -c -e "${FILE}$"` = 0 ]] && (rm -rf "${each}" && echo "Deleted: ${each}" || (echo -e "\033[01;31mWARNING\033[00m: '${each}' was removed upstream but couldn't be deleted here.\n\nPlease delete ${each} manually."; exit 1))
|
||||
if [ $(cat .gitmodules | grep "path = " | grep -o -e "[^\/]*$" | grep -c -e "${FILE}$") = 0 ]; then
|
||||
[[ -z "$FIRST_OLD" ]] && export FIRST_OLD=1 && echo -n -e "\e[44m \e[0m\e[43m + Removing Old Plugins: \e[0m\n"
|
||||
rm -rf "$each"
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "\e[44m \e[0m\e[43m = \e[0m$(echo ${each}\ | sed -re 's|^(.*)/([^/]*)$|\\e\[1;37m\1/\\e\[1;31m\2\\e\[0m|')"
|
||||
else
|
||||
error "$each" "The folder could not be deleted" "Try deleting manually to resolve"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo
|
||||
done && unset FIRST_OLD && echo
|
||||
|
||||
# update git-based plugins in vim/bundle.user if any exist
|
||||
if [ ! $(find vim/bundle.user | grep ".git/config" | wc -l) = 0 ]; then
|
||||
echo "Updating custom plugins in 'vim/bundle.user':"
|
||||
echo -e "\e[44m >> Updating User Plugins >> \e[0m"
|
||||
pushd vim/bundle.user > /dev/null 2>&1
|
||||
for each in *; do
|
||||
if [ -d "$each" ]; then
|
||||
pushd "$each" > /dev/null 2>&1
|
||||
if [ -d .git ]; then
|
||||
echo -e "\nUpdating git repo: ${each}..."
|
||||
git pull
|
||||
elif [ -f .git ]; then
|
||||
echo -e "\nUpdating git submodule: ${each}..."
|
||||
git pull origin master
|
||||
echo -n -e "\e[44m \e[0m\e[43m + Updating 'vim/bundle.user/${each}' \e[0m"
|
||||
GIT_STATUS=$(git pull origin master 2>&1)
|
||||
if [ $? = 0 ]; then
|
||||
if [ $(echo $GIT_STATUS | grep -c "Already up-to-date") = 0 ]; then
|
||||
echo -e "\e[0;32m SUCCESS! \e[0m"
|
||||
else
|
||||
echo -e "\e[1;37m UP TO DATE \e[0m"
|
||||
fi
|
||||
else
|
||||
error "vim/bundle.user/${each}" "Git failed to pull the latest changes" "Git output: ${GIT_STATUS}"
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null 2>&1
|
||||
fi
|
||||
|
@ -58,9 +133,10 @@ if [ ! $(find vim/bundle.user | grep ".git/config" | wc -l) = 0 ]; then
|
|||
echo
|
||||
fi
|
||||
|
||||
echo "Generating updated helpdocs for installed plugins..."
|
||||
[[ `type -P vim` ]] && vim -c "Helptags|qa!" &>/dev/null 2>&1
|
||||
echo
|
||||
echo -n -e "\e[44m >> Generating Plugin Helpdocs: \e[0m"
|
||||
[[ $(type -P vim) ]] && vim -c "Helptags|qa!" &> /dev/null 2>&1 \
|
||||
&& echo -e "\e[0;32m SUCCESS! \e[0m" \
|
||||
|| (echo -e "\e[1;31m FAIL! \e[0m"; error "$vim -c \"Helptags|qa!\"" "Generating helpdocs for the submodules failed")
|
||||
|
||||
echo "Update Complete!"
|
||||
echo -e "\n\e[40m ~~~ Update Complete ~~~ \e[0m\n"
|
||||
exit 0
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c2fd1618e716bb49f1f93d19e0af0da3bfa7d5ea
|
||||
Subproject commit 9ca274d792a9e6f41da2122223127fa2ab6d7a7a
|
Loading…
Reference in a new issue