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

merge.message.body could be a template string

jbergstroem opened this issue · comments

It would be interesting to allow further customization of the message body by providing a simple template (python template string? mustache? plain variables?) that allows for minor customization. I would for one like to add metadata to the body such as committer, reviewer or author and a link to the PR URL (See the node.js project for an example):

Example:

[merge.message]

body = """
$pr_body

PR-URL: $pr_url"""

Thanks for the suggestion.

Kodiak has partial support for some of the metadata you'd like to record.

You can enable merge.message.include_pull_request_url to add the pull request URL to the commit body, but the URL wouldn't have the PR-URL: prefix. Is that something you could live without? Maybe we could update Kodiak to include that prefix to better match the Co-authored-by trailers.

You can use merge.message.include_coauthors to add Co-authored-by trailers to the PR.

Kodiak doesn't have anything to help with Reviewed-By trailers, but it probably wouldn't be hard to support.

If possible, my preference would be to avoid adding template support, but I'm open to the idea if we need to do it

Kodiak has partial support for some of the metadata you'd like to record.

Excellent!

Kodiak doesn't have anything to help with Reviewed-By trailers, but it probably wouldn't be hard to support.

Right. Consider me a user if supported (as well as the "missing PR-URL").

If possible, my preference would be to avoid adding template support, but I'm open to the idea if we need to do it

It would be useful for me to understand your position here; why you think templates is not the path forward. Nitpick, but lets say someone dislike your order? Wants to add emojis (I hear thats a thing now); just overall more flow control if you get me.

@jbergstroem I'm okay with adding templating, but if we can add more boolean options instead I'd prefer that. My thought is that boolean config options are more foolproof, although less flexible, than templating.

This is where Kodiak sets the Co-authored-by trailers and the PR url:

if config.merge.message.include_pull_request_url:
if merge_body.commit_message is None:
merge_body.commit_message = pull_request.url
else:
merge_body.commit_message += "\n\n" + pull_request.url
# we share coauthor logic between include_pull_request_author and
# include_coauthors.
coauthors = [] # type: List[PullRequestCommitUser]
if config.merge.message.include_pull_request_author:
coauthors.append(
PullRequestCommitUser(
login=pull_request.author.login,
databaseId=pull_request.author.databaseId,
name=pull_request.author.name,
type=pull_request.author.type,
)
)
if config.merge.message.include_coauthors:
for commit in commits:
if (
# only use commits that have identified authors.
commit.author is None
or commit.author.user is None
# ignore merge commits. They will have more than one parent.
or commit.parents.totalCount > 1
):
continue
coauthors.append(commit.author.user)
coauthor_trailers = get_coauthor_trailers(
coauthors=coauthors,
include_pull_request_author=config.merge.message.include_pull_request_author,
pull_request_author_id=pull_request.author.databaseId,
)
if coauthor_trailers:
trailer_block = "\n".join(coauthor_trailers)
if merge_body.commit_message:
merge_body.commit_message += "\n\n" + trailer_block
else:
merge_body.commit_message = trailer_block

We'd need to update that code and add another config option here for reviewed-by trailers:

include_coauthors: bool = False
include_pull_request_url: bool = False

@jbergstroem I'm okay with adding templating, but if we can add more boolean options instead I'd prefer that. My thought is that boolean config options are more foolproof, although less flexible, than templating.

Ok – I can see that too. Less is (most often) more. I'll let you carve the path here then; happy to open new requests for PR-URL and Reviewed-by if that makes more sense at the time being.