Skip to content

Commitlint fails after squash merge #67

Closed

Description

@aj3sh

Describe the bug
When a PR is created with a commit message of around 72 characters the commitlint action will pass. But when the PR is Squashed and Merged Github appends the PR number in the commit message. The appended commit message fails the commitlint after the PR is merged.
https://github.com/opensource-nepal/node-nepali-datetime/actions/runs/11974343317
Screenshot 2024-11-22 at 8 42 35 PM

To Reproduce
Pre-requisite: Github Action is set up on the target branch with pull_request and push events.

  1. Create a PR with a commit message of 72 characters.
  2. The commitlint will pass.
  3. Squash and merge the PR.
  4. Leave the commit message GitHub suggests (PR number appended to the commit message).
  5. The commitlint fails after the PR is merged as the commit message length exceeds 72 characters.

Expected behavior
The commitlint should be smart enough to overcome this situation.
Possible Solution:

  • Ignore the appended PR number; common formats ... (#PR) and ... #PR.

Environment

  • Python version: N/A
  • Package version: v1.3.0
  • Operating system: Github Actions
  • Any other relevant information about your environment.

Activity

  1. added
    bugSomething isn't working
    help wantedExtra attention is needed
    on Nov 23, 2024
  2. kiyoon commented on Nov 27, 2024

    @kiyoon

    I think it should have an option to bypass the 72-character limit, and even configure the length. The length limit is not even on the conventional commit spec.

  3. aj3sh commented on Nov 27, 2024

    @aj3sh
    MemberAuthor

    I think it should have an option to bypass the 72-character limit, and even configure the length. The length limit is not even on the conventional commit spec.

    True, the length check should be optional and limit should be configurable.

  4. SiegeSailor commented on Nov 5, 2025

    @SiegeSailor

    Hello @aj3sh, unrelated question. Did you manually change the merge commit message to bypass the commitlint? My action https://github.com/SiegeSailor/Smarty-Notebook/actions/runs/19092271540 failed due to the default merge commit message, and I was looking for an option to ignore the merge and squash commit messages.

  5. aj3sh commented on Nov 6, 2025

    @aj3sh
    MemberAuthor

    Hello @SiegeSailor,
    Auto-generated commits (such as merge, revert, etc.) are skipped by commitlint. However, squash commits are not skipped. We need to update the squash commit message if it doesn’t follow the conventional commit standard. This will help maintain consistency in the repository’s commit history.

    Did you manually change the merge commit message to bypass the commitlint?

    For this, we have added commitlint to PRs as well, so the squash commit messages are usually in the correct format. We do not modify the commit messages.

  6. SiegeSailor commented on Nov 8, 2025

    @SiegeSailor

    Hello @aj3sh, thank you for your prompt reply. Sorry, I must have overlooked the error message:

    ⧗ ci: update action secrets
    Commit validation: successful!
    
    ⧗ 1.0.0-release.7
    Error: ✖ Found 1 error(s).
    - Commit message does not follow the Conventional Commits format.
    
    ⧗ docs: update dependencies format
    Commit validation: successful!
    
    ⧗ Merge pull request #1 from SiegeSailor/release
    Commit validation: successful!
    Error: Process completed with exit code 1.
    

    The failure was actually caused by 1.0.0-release.7, which is an auto-generated commit message by Python Semantic Release. While the auto-generated commit format is configurable (I believe) in PSR, is there a way for commitlint to ignore certain committers? (for example, github-actions)? If this is not here yet but is desired, I can create a PR for this.

  7. aj3sh commented on Nov 9, 2025

    @aj3sh
    MemberAuthor

    Hi @SiegeSailor, commitlint doesn’t have a feature to ignore specific committers. The logic for handling committers hasn’t been implemented in its source code, and I’d prefer not to introduce it unless absolutely necessary. It would be better if we configure the commit format in Python Semantic Release instead; https://python-semantic-release.readthedocs.io/en/latest/configuration/configuration.html#commit-message.

    Another option would be to introduce a custom ignore patterns (perhaps from some ignore file).

  8. SiegeSailor commented on Nov 9, 2025

    @SiegeSailor

    Hello @aj3sh, I ended up with something like below in my releaserc.toml for PSR (see python-semantic-release/python-semantic-release#187 (comment) for details):

    [semantic_release]
    commit_message = """\
    chore: release {version}
    
    Automatically generated by python-semantic-release
    """

    I am not sure how a custom ignore pattern works here. Let me dive deeper into the whole commit linting and automation ecosystem and come back later.

  9. aj3sh commented on Nov 9, 2025

    @aj3sh
    MemberAuthor

    Hello @aj3sh, I ended up with something like below in my releaserc.toml for PSR (see python-semantic-release/python-semantic-release#187 (comment) for details):

    [semantic_release]
    commit_message = """\
    chore: release {version}
    
    Automatically generated by python-semantic-release
    """

    I am not sure how a custom ignore pattern works here. Let me dive deeper into the whole commit linting and automation ecosystem and come back later.

    This looks great.

    The custom ignore pattern hasn't been implemented in commitlint yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions