Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic configuration depending on PR properties #783

Open
jdnavarro opened this issue Jan 21, 2022 · 2 comments
Open

Dynamic configuration depending on PR properties #783

jdnavarro opened this issue Jan 21, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jdnavarro
Copy link

I'm aware you can already override some settings, like the merge method, by passing them on the automerge label, but would it be possible to have the overrides automatically picked (or apply a different configuration altogether) depending on certain properties of the PR?

The particular case I have in mind looks like this:

  1. If a branch PR is only one commit ahead of the target:
    Fast forward the extra commit as it is.

  2. Otherwise:
    Merge avoiding fast-forwarding. The merge commit message will be extracted from the PR description.

Would it be too difficult to implement? Is it something you would accept a PR for?

@jdnavarro jdnavarro added the enhancement New feature or request label Jan 21, 2022
@sbdchd
Copy link
Collaborator

sbdchd commented Jan 26, 2022

Hmm, I'm curious what the API would be like in terms of the config settings & labels for the PR to trigger the behavior.

Having labels override more settings is pretty straightforward to implement, would the different config mean there would be multiple kodiak.toml files in a repo? Maybe different sections in the toml file?

Definitely open to it, but it might be easier to do with a github action

@jdnavarro
Copy link
Author

Ideally, it'd be great to have something along how cargo deals with configuration overrides, see platform specific dependencies.

In the case of kodiak it could look like this:

['pr_predicate(number_commits > 1)'.merge]
method = "merge"
message.title = "pull_request_title"

# Fallback
[merge]
method = "squash"
# message.title already defaults to github_default, 
# which in the case of squash would be the commit message.
# message.title = "github_default"
message.include_coauthors = true # will be always true

I wouldn't mess with specifity rules, later matching keys would override earlier declared ones by default. Perhaps you can have special cases where instead of overriding, the second property would be appended, like adding an extra co-author.

In addition to the number of commits, these predicates could be useful too:

  • Author: i. e. if it's dependabot prioritize merge.
  • Commit/PR message regex: i. e. if the PR title matches the conventional commit scheme include the PR number in the message.
  • Time: i. e. during weekends require label "automerge_force".

Separate configuration files could be implemented as file includes, but that would be a different feature, orthogonal to configuration predicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants