Skip to content

Commit 99b6628

Browse files
authored
Update squash-pr.yml
1 parent 041391f commit 99b6628

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/squash-pr.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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
@@ -57,8 +64,6 @@ jobs:
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

0 commit comments

Comments
 (0)