Skip to content

Commit

Permalink
feat: add original_description to placeholders
Browse files Browse the repository at this point in the history
This allows the user to copy the original pull request description
to the backported PR. This can be helpful if the body contains
links to ticketing systems, related documents etc.

Example usage:

yaml
```
          pull_description: |-
            Automated backport to `${target_branch}`, triggered by a
label in #${pull_number}.

            Original Description:
            ${original_description}
```
  • Loading branch information
jschmid1 committed Jan 22, 2024
1 parent 7a2d0af commit a504725
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ Placeholder | Replaced with
`pull_number` | The number of the original pull request that is backported, e.g. `123`
`pull_title` | The title of the original pull request that is backported, e.g. `fix: some error`
`target_branch`| The branchname to which the pull request is backported, e.g. `release-0.23`
`original_description`| The original description of the pull request you created the backport from, e.g. `Summary: This patch was created to..`

## Outputs

Expand Down
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,11 +990,13 @@ exports.getMentionedIssueRefs = exports.replacePlaceholders = void 0;
* @returns Description that can be used in the backport pull request
*/
function replacePlaceholders(template, main, target) {
var _a;
const issues = getMentionedIssueRefs(main.body);
return template
.replace("${pull_author}", main.user.login)
.replace("${pull_number}", main.number.toString())
.replace("${pull_title}", main.title)
.replace("${original_description", (_a = main.body) !== null && _a !== void 0 ? _a : "")
.replace("${target_branch}", target)
.replace("${issue_refs}", issues.join(" "));
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function replacePlaceholders(
.replace("${pull_author}", main.user.login)
.replace("${pull_number}", main.number.toString())
.replace("${pull_title}", main.title)
.replace("${original_description", main.body ?? "")
.replace("${target_branch}", target)
.replace("${issue_refs}", issues.join(" "));
}
Expand Down

0 comments on commit a504725

Please sign in to comment.