pull/1473/head
cornfeedhobo 2020-01-04 09:41:55 -08:00
parent 3923d2d74b
commit c8d59d7e2d
No known key found for this signature in database
GPG Key ID: 724357093F994B26
1 changed files with 40 additions and 47 deletions

View File

@ -159,55 +159,48 @@ _bash-it-update-repo() {
local remote="${3:-origin}"
local old_pwd="${PWD}"
if [[ ! -d "${dir}" ]] ; then
cd "${dir}" || return 1
return 1
git fetch &> /dev/null
declare status
status="$(git rev-list master.."${remote}/master" 2> /dev/null)"
if [[ -n "${status}" ]]; then
for i in $(git rev-list --merges --first-parent "master..${remote}"); do
num_of_lines=$(git log -1 --format=%B "$i" | awk 'NF' | wc -l)
if [ "$num_of_lines" -eq 1 ]; then
description="%s"
else
description="%b"
fi
git --no-pager log --format="%h: $description (%an)" -1 "$i"
done
echo ""
read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h "${remote}/master")? [Y/n] " RESP
case $RESP in
[yY]|"")
if ! git pull --rebase &> /dev/null
then
echo "${name} successfully updated."
else
echo "Error updating ${name}, please, check if your ${name} installation folder (${dir}) is clean."
fi
;;
[nN])
echo "Not upgrading…"
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
else
cd "${dir}"
git fetch &> /dev/null
declare status
status="$(git rev-list master.."${remote}"/master 2> /dev/null)"
if [[ -n "${status}" ]]; then
for i in $(git rev-list --merges --first-parent master.."${remote}"); do
num_of_lines=$(git log -1 --format=%B "$i" | awk 'NF' | wc -l)
if [ "$num_of_lines" -eq 1 ]; then
description="%s"
else
description="%b"
fi
git --no-pager log --format="%h: $description (%an)" -1 "$i"
done
echo ""
read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP
case $RESP in
[yY]|"")
if ! git pull --rebase &> /dev/null
then
echo "${name} successfully updated."
else
echo "Error updating ${name}, please, check if your ${name} installation folder (${dir}) is clean."
fi
;;
[nN])
echo "Not upgrading…"
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
else
echo "${name} is up to date, nothing to do!"
fi
cd "${old_pwd}" &> /dev/null || return 1
echo "${name} is up to date, nothing to do!"
fi
cd "${old_pwd}" &> /dev/null || return 1
}