From c0ec64cfc22fa947acbe696ad3d609764d195173 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Thu, 28 Oct 2021 19:09:16 +0200 Subject: [PATCH] Check for unpushed changes before system shutdown --- dotfiles/shell/aliases | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dotfiles/shell/aliases b/dotfiles/shell/aliases index 038a8f1..ded9d62 100644 --- a/dotfiles/shell/aliases +++ b/dotfiles/shell/aliases @@ -122,15 +122,22 @@ git-pull-from-repos() { git-check-unpushed() { local start_dir="$PWD" + local unpushed_repos='false' local git_repos=($(find ~ -name .git -type d -not -path '*/.vim/*' -and -not -path '*/.local/*' -and -not -path '*/builds/*' -exec dirname {} \;)) for repo in "${git_repos[@]}"; do cd "$repo" || exit 1 local unpushed=$(git log --pretty=format:'%h' '@{u}..' 2>/dev/null | wc -c) if [ "$unpushed" -ne 0 ]; then echo "Unpushed changes in $repo" + local unpushed_repos='true' fi done cd "$start_dir" || exit 1 + if [ "$unpushed_repos" = 'true' ]; then + return 1 + else + return 0 + fi } hello() { @@ -152,6 +159,7 @@ hello() { } bye() { + git-check-unpushed || return 1 if command -v protonvpn >/dev/null 2>&1; then sudo protonvpn d fi