commit-message-checker icon indicating copy to clipboard operation
commit-message-checker copied to clipboard

Exclude merge commits from checks

Open ArjenVanDerWeijden opened this issue 3 years ago • 1 comments

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • [X] I have searched the existing issues

Are you willing to sponsor your idea?

  • [ ] Yes, I like to sponsor this request

Is your feature request related to a problem? Please describe

We are trying to automate, checking whether commits match a regex - your action works great.

Unless it's a merge commit (e.g. locally a developer merged one branch into another, created a merge commit and pushed that).

The commit message will not match the desired regex.

Describe the solution you'd like

You can check if a commit is a merge commit:

git cat-file -p $commit_id

If there's more than one `parent' line in the output, you found a merge.

If there's a "ignoreMergeCommits" setting acitvated, then do not even test for the regex (just list it as 'ignored'?)

Describe alternatives you've considered

No response

Additional context

No response

ArjenVanDerWeijden avatar May 30 '22 11:05 ArjenVanDerWeijden

Hi @ArjenVanDerWeijden,

There are a couple of things here:

  • If you are merging the main branch onto your feature branch that will create the merge commit in your pull request and the action will fail the check. In this scenario you should use rebase instead merge to update a branch because you are introducing an unwanted commit in your history.
  • If the merge commit is generated after you merge a branch, the action should not fail unless you run the action for "merged pull requests" and "open pull requests".

In any of these cases, what you can do is configure your repository settings to change the "merge commit" format.

Screenshot from 2023-05-17 06-16-00

codebydant avatar May 17 '23 11:05 codebydant