Skip to content

Commit

Permalink
Merge pull request #8779 from ministryofjustice/fix/git-commit-script
Browse files Browse the repository at this point in the history
Graceful handling of git commit in `git-commit.sh`
  • Loading branch information
mikereiddigital authored Dec 27, 2024
2 parents 8e229fe + b5ce772 commit 93289e9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/git-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ commit_message="Workflow: created files in ${1}"

git checkout -b "$branch"
git add "$1"
git commit -m "$commit_message"

commit_success=$?
if [ $commit_success -ne 0 ]; then
echo "Nothing to commit"
# Check if there are any changes to commit
if git diff-index --quiet HEAD --; then
echo "Nothing to commit, working tree clean"
exit 0
fi

git commit -m "$commit_message"

git remote rm origin || true
git remote add origin "https://${TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push -u origin "$branch"

git status
git status

0 comments on commit 93289e9

Please sign in to comment.