Skip to content

Commit

Permalink
new feature: empty_commit parameter
Browse files Browse the repository at this point in the history
User can choose if they want to push a empty commit or not. Optional .env flag, values: yes || no. Default value: yes
  • Loading branch information
Staubgeborener committed Feb 23, 2024
1 parent 67929a3 commit 432cb31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source "$parent_path"/.env

backup_folder="config_backup"
backup_path="$HOME/$backup_folder"
empty_commit=${empty_commit:-"yes"}
git_host=${git_host:-"github.com"}
full_git_url="https://"$github_token"@"$git_host"/"$github_username"/"$github_repository".git"

Expand Down Expand Up @@ -122,7 +123,7 @@ 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
if [[ "$empty_commit" = "yes" && $(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"
Expand Down

0 comments on commit 432cb31

Please sign in to comment.