chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs

Home Page:https://kodiakhq.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

better support dependabot PR descriptions

staabm opened this issue · comments

merging a dependabot PR produces a really ugly commit message, because of all the html involved in the PR description dependabot uses.

maybe the problem is even more general, but in our case its most annoying with dependabot, because the bots regularily sends pull requests.

example commit after kodiak merge

grafik

commit body as text

Updates the requirements on [phpstan/phpstan](phpstan/phpstan) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/phpstan/phpstan/releases">phpstan/phpstan's releases</a>.</em></p>
<blockquote>
<h2>0.12.86</h2>
<h1>Improvements 🔧</h1>
<ul>
<li>Inline <code>@throws</code> support (<a href="https://github.com/phpstan/phpstan-src/commit/48bfa70312035102e3cc781d9ed23d02ec0e6bc9">https://github.com/phpstan/phpstan-src/commit/48bfa70312035102e3cc781d9ed23d02ec0e6bc9</a>)</li>
<li>Updated PHP-Parser to 4.10.5 (<a href="https://github.com/phpstan/phpstan-src/commit/4ee1fa1df8821c84885576c31cbf92d0c663d80d">https://github.com/phpstan/phpstan-src/commit/4ee1fa1df8821c84885576c31cbf92d0c663d80d</a>)</li>
</ul>
<h1>Bugfixes 🐛</h1>
<ul>
<li><code>new ReflectionClass()</code> can throw <code>ReflectionException</code> (<a href="https://github.com/phpstan/phpstan-src/commit/00d3ef418f672f1aa012ed26ce6d09cf6a510cec">https://github.com/phpstan/phpstan-src/commit/00d3ef418f672f1aa012ed26ce6d09cf6a510cec</a>)</li>
<li>Fix PHPStan Pro reanalyse results (<a href="https://github.com/phpstan/phpstan-src/commit/179b2131dec2e3b2f7147a707e278e45eadbe863">https://github.com/phpstan/phpstan-src/commit/179b2131dec2e3b2f7147a707e278e45eadbe863</a>)</li>
<li><code>DateTime</code> and <code>DateTimeImmutable</code> constructor does not always throw Exception (<a href="https://github.com/phpstan/phpstan-src/commit/181f75ce89a521aebc0336a61352b821645c738a">https://github.com/phpstan/phpstan-src/commit/181f75ce89a521aebc0336a61352b821645c738a</a>)</li>
<li>Do not attempt to autoload invalid classnames (<a href="https://github.com/phpstan/phpstan-src/commit/56566eb9a94698b6268cc11c25323cdff30d1758">https://github.com/phpstan/phpstan-src/commit/56566eb9a94698b6268cc11c25323cdff30d1758</a>), <a href="https://github-redirect.dependabot.com/phpstan/phpstan/issues/4953">#4953</a></li>
</ul>
<h1>Function signature fixes 🤖</h1>
<ul>
<li>Fixed <code>wincache_ucache_inc</code> and <code>wincache_ucache_dec</code> (<a href="https://github.com/phpstan/phpstan-src/commit/671f404140fd18e19f43368bcc78eb64aab9380e">https://github.com/phpstan/phpstan-src/commit/671f404140fd18e19f43368bcc78eb64aab9380e</a>), <a href="https://github-redirect.dependabot.com/phpstan/phpstan/issues/4952">#4952</a></li>
<li>Fixed <code>Redis::scan()</code> signature (<a href="https://github.com/phpstan/phpstan-src/commit/8fe9e606b54366a5aa217bff0928cb8dda7a9378">https://github.com/phpstan/phpstan-src/commit/8fe9e606b54366a5aa217bff0928cb8dda7a9378</a>), <a href="https://github-redirect.dependabot.com/phpstan/phpstan/issues/4929">#4929</a></li>
<li><code>IntlDateFormatter::parse</code> can define variable by reference (<a href="https://github-redirect.dependabot.com/phpstan/phpstan-src/pull/509">#509</a>), thanks <a href="https://github.com/francescolaffi"><code>@​francescolaffi</code></a>!</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/phpstan/phpstan/commit/a84fdc53ecca7643dbc89ef8880d8b393a6c155a"><code>a84fdc5</code></a> PHPStan 0.12.86</li>
<li><a href="https://github.com/phpstan/phpstan/commit/4ab7474a36e9bb0fa6c221ffbab19d0b32a6f204"><code>4ab7474</code></a> Updated PHPStan to commit ea1313b0fd43b5bc4089c9aac5aee8dc5056678a</li>
<li><a href="https://github.com/phpstan/phpstan/commit/b91ca1d460f4b7dd9504034291c49b088cce992e"><code>b91ca1d</code></a> Updated PHPStan to commit e4f7faac9557c041fdb2cbc89208549e7bf038b4</li>
<li><a href="https://github.com/phpstan/phpstan/commit/a897b46373eb3132e43fce77732caee48d3b6109"><code>a897b46</code></a> Updated PHPStan to commit 62a282f1c22dd3117d6a2a24435d8f4c86a918e2</li>
<li><a href="https://github.com/phpstan/phpstan/commit/5abfd3b7a7cdff541a81de4076f5c0ec28390b3d"><code>5abfd3b</code></a> Do not fail-fast</li>
<li><a href="https://github.com/phpstan/phpstan/commit/216fbb96d97ac1ac2288efa5768d07802e8ea507"><code>216fbb9</code></a> Separate workflows</li>
<li><a href="https://github.com/phpstan/phpstan/commit/497d188d08f1efe675d99fc5bdb28edd08afb489"><code>497d188</code></a> Fix Rector build</li>
<li><a href="https://github.com/phpstan/phpstan/commit/212148509f7c218cb78bd336cd9d549b2c38e793"><code>2121485</code></a> Updated PHPStan to commit 56566eb9a94698b6268cc11c25323cdff30d1758</li>
<li><a href="https://github.com/phpstan/phpstan/commit/5222cddfbc5f84d7abc9c2047f511f7ab7ab3b2b"><code>5222cdd</code></a> Reproduce <a href="https://github-redirect.dependabot.com/phpstan/phpstan/issues/4953">#4953</a></li>
<li><a href="https://github.com/phpstan/phpstan/commit/ef8e5e487933797d605d0fe3299001bc38a848aa"><code>ef8e5e4</code></a> Bump hosted-git-info from 2.8.8 to 2.8.9 in /website</li>
<li>Additional commits viewable in <a href="https://github.com/phpstan/phpstan/compare/0.12.85...0.12.86">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself.

.kodiak.toml

# DONT EDIT THIS FILE OUTSIDE OF complex-gmbh/php-automation-templates
# changes will be one-way synced from the automation repos

# .kodiak.toml
version = 1

[merge]
method = "squash"
# once a PR is merged into master, delete the branch
delete_branch_on_merge = true
# label to use to enable Kodiak to merge a PR
automerge_label = ["automerge", "kodiak: merge.method = 'merge'"]
# require that the automerge label be set for Kodiak to merge a PR. if you
# disable this Kodiak will immediately attempt to merge every PR you create
require_automerge_label = true
# if a PR is passing all checks and is able to be merged, merge it without
# placing it in the queue. This will introduce some unfairness where those
# waiting in the queue the longest will not be served first.
prioritize_ready_to_merge = true
# Kodiak will not merge a PR with any of these labels.
blacklist_labels = ["misses-clxLBE"]

[merge.message]
title = "pull_request_title"
body = "pull_request_body"
include_pr_number = true
include_coauthors = true
# remove html comments to auto remove PR templates
strip_html_comments = true
# cut PR badges from https://pullrequestbadge.com/
cut_body_before = "<!-- PR-BADGE: PLEASE DO NOT REMOVE THIS COMMENT -->"
# cut dependabot chatty descriptions
cut_body_after = "Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself."

[update]
# update PR whenever the PR is out of date with the base branch. PR will be
# updated regardless of failing status checks, missing reviews, merge blacklist
# labels, etc. Kodiak will only update the PR if the automerge label is attached
# or `update.require_automerge_label` is false.
always = true
require_automerge_label = true

expected result: the commit message should be human readable.

@staabm Would selecting the "plain_text" body type work for you?

Here's a Gist comparing the body types (markdown, HTML, text): https://gist.github.com/chdsbd/649c4bfdf855a71d20eeeae6a6e8d50a

I used this PR for an example: redaxo/redaxo#4672

Oh nice. Plaintext looks great 😊

Is it be possible to use plain-text for dependabot PRs only?

If not, maybe the body_type-option could be made configurable via a PR label?

I think if we wanted to add a new configuration option, it could look something like:

# .kodiak.toml
[merge.automerge_dependencies]
message.body_type = "plain_text"

Adding another label-configurable option would look similar to the merge_method label:

# parse merge.method override label
# example: `kodiak: merge.method = "rebase"`
for label in labels:
if not label.startswith("kodiak:"):
continue
# we have an existing label "kodiak:disabled". This label will not parse
# here and will be ignored.
_start, _sep, maybe_config = label.partition("kodiak:")
try:
merge_method_override = MergeMethodOverride.parse_obj(
toml.loads(maybe_config)
)
except (toml.TomlDecodeError, pydantic.ValidationError):
continue
return merge_method_override.merge.method

having it configurable as a PR label, would open the door to use it with other merge-bots or workflows (or even different use-cases with different problems).

if its not too complicated, I would go for the label-solution (instead of a very limited new config key)