Skip to content

Commit

Permalink
Merge branch 'main' into fix-docs-typo
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Sep 8, 2024
2 parents 32f41c0 + d39f0b2 commit 5ec2ace
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
36 changes: 22 additions & 14 deletions docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Default: `backport`

#### `branchLabelMapping`

Automatically detech which branches a pull request should be backported to, based on the pull request labels.
Automatically detect which branches a pull request should be backported to, based on the pull request labels.

```json
{
Expand Down Expand Up @@ -340,27 +340,35 @@ Template values:

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

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

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

```
{{targetBranch}} {{sourcePullRequest.title}}
```json
{
"prTitle": "[{{targetBranch}}] {{commitMessages}}"
}
```

**Example**
**Example: Slightly more verbose**

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

See [source code](https://github.com/sorenlouv/backport/blob/7c998dd05bda06e9979409cc4e63273bad711d11/src/lib/github/v3/createPullRequest.test.ts#L340-L522) for more examples
**Example: Use original PR title prefixed by branch**

```json
{
"prTitle": "{{targetBranch}} {{sourcePullRequest.title}}"
}
```

See [source code](https://github.com/sorenlouv/backport/blob/main/src/lib/github/v3/createPullRequest.test.ts) for more examples.

#### `prDescription`

Expand All @@ -371,7 +379,7 @@ The description uses the [handlebars templating engine](https://handlebarsjs.com
- `{{targetBranch}}`: Branch the backport PR will be targeting
- `{{commitMessages}}`: Message of backported commit. For multiple commits the messages will be separated by new lines (`|`).
- `{{defaultPrDescription}}`: The default PR description. Using this makes it easy to append and prepend text to the existing description
- `{{commits}}`: A list of commit objects (see [commit interface](https://github.com/sorenlouv/backport/blob/9e42503a7d0e06e60c575ed2c3b7dc3e5df0dd5c/src/lib/sourceCommit/parseSourceCommit.ts#L15-L36))
- `{{commits}}`: A list of commit objects (see [`Commit` interface](https://github.com/sorenlouv/backport/blob/main/src/lib/sourceCommit/parseSourceCommit.ts))

**Example: List commits**

Expand All @@ -389,7 +397,7 @@ For people who often want to append the same text, they can create a bash alias:
alias backport-skip-ci='backport --pr-description "{defaultPrDescription} [skip-ci]"'
```

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

#### `prFilter`

Expand Down Expand Up @@ -525,7 +533,7 @@ Branch name to use for the backport PR
Template values:

- `{{targetBranch}}`: Branch the backport PR will be targeting
- `{{sourcePullRequest}}`: Original pull request object (see [interface](https://github.com/sorenlouv/backport/blob/9e42503a7d0e06e60c575ed2c3b7dc3e5df0dd5c/src/lib/sourceCommit/parseSourceCommit.ts#L23-L31))
- `{{sourcePullRequest}}`: Original pull request object (see [`Commit` interface](https://github.com/sorenlouv/backport/blob/main/src/lib/sourceCommit/parseSourceCommit.ts))
- `{{refValues}}`: Name representing the original commit/PR, `commit-<hash>` or `pr-<pr number>` respectively.

Default: `backport/{{targetBranch}}/{{refValues}}`
Expand All @@ -538,4 +546,4 @@ Default: `backport/{{targetBranch}}/{{refValues}}`
}
```

See [source code](https://github.com/sorenlouv/backport/blob/main/src/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.ts#L14).
See [source code](https://github.com/sorenlouv/backport/blob/main/src/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.ts).
6 changes: 3 additions & 3 deletions src/lib/child-process-promisified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export async function spawnPromise(
const subprocess = childProcess.spawn(cmd, cmdArgs, {
cwd,

// ensure that git commands return english error messages
env: { ...process.env, LANG: 'en_US' },
// ensure that git commands return English error messages
env: { ...process.env, LANG: 'C' },
...(isInteractive ? { stdio: 'inherit' } : undefined),
});
let stderr = '';
Expand Down Expand Up @@ -95,7 +95,7 @@ export const spawnStream = (cmd: string, cmdArgs: ReadonlyArray<string>) => {
const spawnSpan = startSpawnSpan(cmd, cmdArgs);

const res = childProcess.spawn(cmd, cmdArgs, {
env: { ...process.env, LANG: 'en_US' },
env: { ...process.env, LANG: 'C' },
});

res.on('close', (code) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { runBackportViaCli } from './runBackportViaCli';
const accessToken = getDevAccessToken();
const octokit = new Octokit({ auth: accessToken });

jest.setTimeout(15_000);
jest.setTimeout(25_000);

describe('backport-org/repo-with-reviewed-pull-requests', () => {
let pullRequest: Awaited<ReturnType<typeof getPullRequest>>;
Expand Down

0 comments on commit 5ec2ace

Please sign in to comment.