Skip to content

Commit

Permalink
Update prTitle templating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Aug 30, 2023
1 parent 7c998dd commit 471b401
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,30 @@ Only list commits touching files under the specified path
Title for the target pull request
Template values:

- `{{sourceBranch}}`: Branch the commit is coming from (usually `main`)
- `{{targetBranch}}`: Branch the backport PR will be targeting
- `{{commitMessages}}`: Message of backported commit. For multiple commits the messages will be separated by pipes (`|`).
- `{{commits}}`: A list of commits ([interface](https://github.com/sqren/backport/blob/9e42503a7d0e06e60c575ed2c3b7dc3e5df0dd5c/src/lib/sourceCommit/parseSourceCommit.ts#L15-L36))

Default: `"[{{targetBranch}}] {{commitMessages}}"`

**Example: Use original PR title prefixed by branch**

```
{{targetBranch}} {{commits.0.sourcePullRequest.title}}
```


**Example**

```json
{
"prTitle": "{{commitMessages}} backport for {{targetBranch}}"
}
```

See [source code](https://github.com/sqren/backport/blob/7c998dd05bda06e9979409cc4e63273bad711d11/src/lib/github/v3/createPullRequest.test.ts#L340-L522) for more examples

#### `prDescription`

Description for the target pull request
Expand All @@ -360,25 +373,24 @@ The description uses the [handlebars templating engine](https://handlebarsjs.com
- `{{defaultPrDescription}}`: The default PR description. Using this makes it easy to append and prepend text to the existing description
- `{{commits}}`: A list of commits ([interface](https://github.com/sqren/backport/blob/9e42503a7d0e06e60c575ed2c3b7dc3e5df0dd5c/src/lib/sourceCommit/parseSourceCommit.ts#L15-L36))

**Example: List commits**

```
{{#each commits}}
{{shortSha this.sourceCommit.sha}} {{this.sourceCommit.message}}
{{/each}}
```

```json
{
"prDescription": "Backports the following commits to {{targetBranch}}:\n{{commitMessages}}"
}
```
**Example: append test to default description**

**Example**
For people who often want to append the same text, they can create a bash alias:

```sh
alias backport-skip-ci='backport --pr-description "{defaultPrDescription} [skip-ci]"'
```

See [source code](https://github.com/sqren/backport/blob/7c998dd05bda06e9979409cc4e63273bad711d11/src/lib/github/v3/createPullRequest.test.ts#L340-L522) for more examples

#### `prFilter`

Filter source pull requests by any [Github query](https://help.github.com/en/github/searching-for-information-on-github/understanding-the-search-syntax). Text with whitespace [must contain escaped quotes](https://help.github.com/en/github/searching-for-information-on-github/understanding-the-search-syntax#use-quotation-marks-for-queries-with-whitespace).
Expand Down

0 comments on commit 471b401

Please sign in to comment.