Skip to content

Commit

Permalink
When backups are up to date still push an empty commit with commit me…
Browse files Browse the repository at this point in the history
…ssage informing that a backup was ran but no changes occurred (#43)
  • Loading branch information
Tylerjet committed Jan 29, 2024
1 parent 922ee2e commit c82d3be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c82d3be

Please sign in to comment.