kodiak icon indicating copy to clipboard operation
kodiak copied to clipboard

Supporting restricting pull request titles to conventional commits

Open blacha opened this issue 5 years ago • 2 comments
trafficstars

I have a number of projects that I use both conventional commits and kodiak

We have generally standardized on a config that looks something like

version = 1

[merge]
method = "squash" 
automerge_label = "automerge 🚀"
prioritize_ready_to_merge = true 

[merge.message]
title = "pull_request_title"

[approve]
auto_approve_usernames = ["dependabot"]

My goal is to prevent pull requests being merged unless their title matches conventional commits.

I have regexp that could be used for a whitelist ^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?(!)?(: (.*\s*)*))$

Do you have any thoughts on how we could restrict pull requests that match this filter

blacha avatar Nov 05 '20 23:11 blacha

Kodiak currently doesn't support linting pull requests, but I don't think it would be too hard to add.

For reference, expanding Kodiak to lint PRs was previously mentioned here: https://github.com/chdsbd/kodiak/issues/521#issuecomment-708069237

I think the config could look something like this:

[pull_request.requirement]
# require conventional commit format
title_regex = "^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?(!)?(: (.*\s*)*))$"

The implementation would be similar to merge.blocking_title_regex, except we'd set a blocking status check on the pull request: https://github.com/chdsbd/kodiak/blob/2ecca4ed181432b192292084719e3796d9997812/bot/kodiak/evaluation.py#L708-L719

As a workaround you might be able to find a GitHub Action that meets this need.

chdsbd avatar Nov 06 '20 00:11 chdsbd

Thanks for responding so quickly

As a workaround you might be able to find a GitHub Action that meets this need.

There does seem to be a few github apps that support this feature eg https://github.com/apps/title-lint I didn't really want to install another app and configure it just to validate titles.

When I saw the blocking_title_regex I thought there might be a easy way to handle this inside kodiak :)

blacha avatar Nov 08 '20 20:11 blacha