From 1cdc686fbee2821ce9eda1dfd6f79ac52da68f4e Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Thu, 9 Sep 2021 22:08:24 +0200 Subject: [PATCH] Add function to check for unpushed repos --- dotfiles/shell/aliases | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dotfiles/shell/aliases b/dotfiles/shell/aliases index 1a326e1..13e55b5 100644 --- a/dotfiles/shell/aliases +++ b/dotfiles/shell/aliases @@ -117,6 +117,19 @@ pull_from_repos() { cd "$start_dir" || exit 1 } +check_unpushed() { + local start_dir="$PWD" + 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}..' | wc -c) + if [ "$unpushed" -ne 0 ]; then + echo "Unpushed changes in $repo" + fi + done + cd "$start_dir" || exit 1 +} + hello() { if command -v protonvpn >/dev/null 2>&1; then sudo protonvpn c --cc NL