From c82d3be35b0ab757402e5dc00985b243f788f81b Mon Sep 17 00:00:00 2001 From: MrTylerjet Date: Mon, 29 Jan 2024 01:28:54 -0700 Subject: [PATCH] When backups are up to date still push an empty commit with commit message informing that a backup was ran but no changes occurred (#43) --- script.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script.sh b/script.sh index 74960b6..73b2de8 100755 --- a/script.sh +++ b/script.sh @@ -114,6 +114,10 @@ fi cd "$backup_path" git add . git commit -m "$commit_message" +# Check if HEAD still matches remote (Means there are no updates to push) and create a empty commit just informing that there are no new updates to push +if [[ $(git rev-parse HEAD) == $(git ls-remote $(git rev-parse --abbrev-ref @{u} 2>/dev/null | sed 's/\// /g') | cut -f1) ]]; then + git commit --allow-empty -m "$commit_message - No new changes pushed" +fi git push -u origin "$branch_name" # Remove files except .git folder after backup so that any file deletions can be logged on next backup