File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,17 +38,24 @@ jobs:
3838
3939 # Step 3: Squash commits and create a detailed commit message
4040 - name : Squash Commits and Generate Message
41- id : squash
4241 run : |
4342 set -e # Exit on error
4443 BASE_BRANCH=${{ github.event.pull_request.base.ref }}
4544 MERGE_BASE=$(git merge-base origin/$BASE_BRANCH HEAD)
4645
46+ echo "Found merge base: $MERGE_BASE"
47+
4748 # Get the subject of the very first commit for the new title
48- COMMIT_SUBJECT=$(git log --reverse --format=%s ${{ env. MERGE_BASE }} ..HEAD | head -n 1)
49+ COMMIT_SUBJECT=$(git log --reverse --format=%s $MERGE_BASE..HEAD | head -n 1)
4950
5051 # Get a formatted list of all commit messages for the new body
51- COMMIT_BODY=$(git log --format="* %s (%h)" ${{ env.MERGE_BASE }}..HEAD)
52+ COMMIT_BODY=$(git log --format="* %s (%h)" $MERGE_BASE..HEAD)
53+
54+ # Add a check to prevent empty commits
55+ if [ -z "$COMMIT_SUBJECT" ]; then
56+ echo "Could not determine a commit subject. Aborting."
57+ exit 1
58+ fi
5259
5360 echo "New commit subject: $COMMIT_SUBJECT"
5461
5764
5865 # Create the new commit with the detailed message
5966 git commit -m "$COMMIT_SUBJECT" -m "$COMMIT_BODY"
60- env :
61- MERGE_BASE : ${{ steps.squash.outputs.merge_base }}
6267
6368
6469 # Step 4: Force-push the squashed commit
You can’t perform that action at this time.
0 commit comments