From b7e623568c3c5f2287ca22d497e7100732c5da58 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 28 Apr 2024 12:25:42 -0300 Subject: [PATCH] Auto-skip chezmoi update in full-upgrade on unpushed changes --- home/dot_local/bin/executable_full-upgrade.tmpl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/home/dot_local/bin/executable_full-upgrade.tmpl b/home/dot_local/bin/executable_full-upgrade.tmpl index 61b6460..d3d2b2f 100644 --- a/home/dot_local/bin/executable_full-upgrade.tmpl +++ b/home/dot_local/bin/executable_full-upgrade.tmpl @@ -30,12 +30,18 @@ if [[ "${CONTINUE_FROM_DOTFILES:-false}" == false ]]; then if chezmoi --version &>/dev/null; then log_task "Updating dotfiles" - # Pull latest changes from dotfiles repo + if chezmoi git -- status --porcelain | grep -q .; then - log_manual_action "Not running chezmoi update as uncommitted dotfiles changes were found" + log_manual_action "Skipping chezmoi update as uncommitted changes were found" + elif ! chezmoi git -- branch --show-current | grep -q .; then + log_manual_action "Skipping chezmoi update as the current branch could not be determined" + elif chezmoi git -- log '@{u}..' | grep -q .; then + log_manual_action "Skipping chezmoi update as unpushed changes were found" else + # Pull latest changes from dotfiles repo c chezmoi update --apply=false fi + # Apply changes to chezmoi config c chezmoi init --force # Apply the rest