Skip to content

bug(ci): commit message validation checks the wrong object under pull_request #894

@Sober7135

Description

@Sober7135

Describe the bug, including details regarding any error messages, version, and platform.

Repository policy

CONTRIBUTING.md states that all pull requests are squash merged.

However, #876 adds a CI check that validates the wrong object under the pull_request event.

Current behavior

#876 validates the merge-ref commit message

- name: Validate commit message format
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
echo "$COMMIT_MSG" > .git/COMMIT_EDITMSG
pre-commit run --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG

Under pull_request, actions/checkout checks out the PR merge ref by default, not the PR head commit.

A temporary reproduction in PR #892 , action see https://github.com/apache/incubator-graphar/actions/runs/22542566764/job/65299867120?pr=892
In this action, I added cat .git/COMMIT_EDITMSG,

    - name: Validate commit message format
      run: |
        COMMIT_MSG=$(git log -1 --pretty=%B)
        echo "$COMMIT_MSG" > .git/COMMIT_EDITMSG
        cat .git/COMMIT_EDITMSG
        pre-commit run --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG 

the output is

Merge 8255be0ba41d4142ecaae5296aaa79c25f3e639a into d535a437667c6e2bf28f7f376930b13ed5aed63d

And see also:

Expected behavior

Under squash merge, the meaningful metadata for what lands in main is the PR title / final squash commit message.

And I think we should add this CI for all PRs not just C++ PR

Component(s)

Developer Tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions