Skip to content

Commit 0ecf6c4

Browse files
authored
github: Fix commit message parsing (#8817)
1 parent 8b87a54 commit 0ecf6c4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.github/actions/get-commit-msg/action.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ runs:
99
if: github.event_name == 'push'
1010
shell: bash
1111
run: |
12+
AUTHOR_NAME="${{ github.event.head_commit.author.name }}"
13+
AUTHOR_EMAIL="${{ github.event.head_commit.author.email }}"
14+
TSTAMP="${{ github.event.head_commit.timestamp }}"
15+
echo "commit ${{ github.event.head_commit.id }}" >> /tmp/commit_msg.txt
16+
echo "Author: ${AUTHOR_NAME}<${AUTHOR_EMAIL}>" >> /tmp/commit_msg.txt
17+
echo "Date: ${TSTAMP}" >> /tmp/commit_msg.txt
18+
echo "" >> /tmp/commit_msg.txt
1219
echo "${{ github.event.head_commit.message }}" >> /tmp/commit_msg.txt
1320
- name: Checkout code
1421
shell: bash
@@ -18,16 +25,19 @@ runs:
1825
echo "hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
1926
git checkout ${{ github.event.pull_request.head.ref }}
2027
COMMIT_MESSAGE=$(git log -1)
21-
echo "${COMMIT_MESSAGE}" >> /tmp/commit_msg.txt
28+
echo "$(git log -1)" >> /tmp/commit_msg.txt
2229
- shell: bash
2330
id: action_output
2431
run: |
2532
DELIMITER="EOF_FILE_CONTENT_$(date +%s)" # Using timestamp to make it more unique
2633
echo "msg<<$DELIMITER" >> "$GITHUB_OUTPUT"
2734
cat /tmp/commit_msg.txt >> "$GITHUB_OUTPUT"
2835
echo "$DELIMITER" >> "$GITHUB_OUTPUT"
36+
echo "----- got commit message ---"
37+
cat /tmp/commit_msg.txt
38+
echo "----------------------------"
2939
- name: Uncheckout code
3040
shell: bash
3141
if: github.event_name == 'pull_request'
3242
run: |
33-
git checkout ${{ steps.checkout.outputs.hash }}
43+
git checkout ${{ steps.checkout_code.outputs.hash }}

test/renderdiff/src/commit_msg.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@
2121

2222
def _parse_commit(commit_str):
2323
lines = commit_str.split('\n')
24-
if len(lines) >= 4:
24+
if len(lines) >= 5:
2525
commit, author, date, _, title, *desc = lines
2626
else:
2727
print(commit_str, file=sys.stderr)
28-
return (
29-
lines[0],
30-
lines[1],
31-
'',
32-
)
28+
return (commit_str, '', '')
29+
3330
commit = commit.split(' ')[1]
3431
title = title.strip()
3532

0 commit comments

Comments
 (0)