sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
241 stars 57 forks source link

Provide the upstream PR title as a template variable to build the backported PRs title #455

Closed waiting-for-dev closed 10 months ago

waiting-for-dev commented 1 year ago

First of all, let me thank you for this great tool on behalf of the Solidus team. We're using it to streamline backports, and it provides an excellent developer experience.

We have, nonetheless, a minor inconvenience with it. Our git flow consists of merging contributions into the main branch. Unfortunately, that translates into creating backport PRs that use the name of the merge commit as its title (see https://github.com/solidusio/solidus/pull/4711 for an example). As our flow also allows for several commits in a single PR, we can't leverage the ${commitMessages} (see #125) template variable to build a custom title. Ideally, we'd like to use the original PR title and prefix it with the branch name. That would be possible if another ${upstreamPRTitle} (or whatever name) template variable was added.

Alternatively, the sister GitHub action could output the created PRs numbers, so we could leverage the GitHub API to update the title on a second step.

Thanks for any help.

sorenlouv commented 10 months ago

Hey there,

Sorry for the late reply. You should be able to achieve this in the latest version (v9.2.2) using this approach:

prTitle: "[{{targetBranch}}] {{commits.0.sourcePullRequest.title}}"

That will set the pull request title to something like [v3.1] Do not pass arrays to can?.

sorenlouv commented 10 months ago

Please let me know if this solves the problem, and if you can think of other cases not solved by this. Please also check the docs that describe which template variables are available: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#prtitle

waiting-for-dev commented 10 months ago

Thanks for your work on that, @sqren. I've created a PR in our project to do as you suggest, and I have tried it on a local fork and it works like a charm. Many thanks for your support.

sorenlouv commented 10 months ago

Great to hear! Thanks for the feedback.