conventional-changelog / commitlint

📓 Lint commit messages
https://commitlint.js.org
MIT License
16.93k stars 912 forks source link

feat: Lint PR Title #4146

Closed mircea-pavel-anton closed 1 month ago

mircea-pavel-anton commented 2 months ago

Expected Behavior

Generally, when I merge a PR back into main, I also squash the commit to keep the git history clean. Thus, running commitlint on the individual commits in the PR makes little sense. I would like to be able to also run commitlint on the PR title and just have it fail if it is not ok

Current Behavior

Currently, it seems we can only lint all the commits inside a PR

Affected packages

Possible Solution

No response

Context

No response

pat-s commented 1 month ago

You can echo the env var that holds the PR title and pipe it into commitlint:

echo "${{ github.event.pull_request.title }}" | commitlint
mircea-pavel-anton commented 1 month ago

@pat-s thank you for the reply!

That's precisely what I ended up doing. I forgot to comment back and close this 😅