From 1771367320294e9512be18e32794c775c0f250ef Mon Sep 17 00:00:00 2001 From: Marissa Staib Date: Wed, 25 Sep 2019 23:13:35 +0000 Subject: [PATCH] Autocommitted updated scripts from blocky-cafe --- bash_aliases.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bash_aliases.sh b/bash_aliases.sh index 5636f80..b95c901 100644 --- a/bash_aliases.sh +++ b/bash_aliases.sh @@ -58,14 +58,20 @@ function sync_git_only() { ( cd "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )" - needs_push=false if git add . && ! git diff-index --cached --quiet HEAD; then - git commit -am "Autocommitted updated scripts from ${hostname}" - needs_push=true + git commit -am "Autocommitted updated scripts from $(hostname)" fi git pull --rebase - if [[ "$needs_push" == "true" ]]; then - git push + if ! git diff --exit-code origin/master master; then + git log --reverse origin..master + if ! read "OK to push these changes? (Y/N) " confirm; then + confirm = "N" + fi + if [[ "$confirm" != "Y" ]]; then + echo "Not pushing yet." + else + git push + fi fi ) }