From 3ebe14d2e4250bd2523af9af514f6add1a82518d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Thu, 5 Sep 2024 19:06:17 +0200 Subject: [PATCH 1/3] Increase timeout of unit test (#508) --- .../cli/copy-reviewers-to-target-pull-request.private.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.ts b/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.ts index f49be96f..351c3afd 100644 --- a/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.ts +++ b/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.ts @@ -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>; From c82454716791cff0895edc4070ac4215ef1b71d1 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Fri, 6 Sep 2024 08:57:47 +0200 Subject: [PATCH 2/3] Spawn processes with LANG that's guaranteed to exist (#506) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `LANG=en_US` is not guaranteed to exist on any system (it does not, for strange reasons, exist on mine). Choose `LANG=C`, which is guaranteed to exist. It has the side-effect of typically using an encoding other than UTF-8 for the tool output (e.g., ISO 8859-1). Apart from messages printed into the log in this encoding that should hopefully have no negative side-effects. See https://github.com/sorenlouv/backport/pull/505 for a case where code was assuming that output would always be English, and failed if it wasn't. Co-authored-by: Søren Louv-Jansen --- src/lib/child-process-promisified.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/child-process-promisified.ts b/src/lib/child-process-promisified.ts index b60a4dd8..400fee1c 100644 --- a/src/lib/child-process-promisified.ts +++ b/src/lib/child-process-promisified.ts @@ -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 = ''; @@ -95,7 +95,7 @@ export const spawnStream = (cmd: string, cmdArgs: ReadonlyArray) => { 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) => { From d39f0b2b99e26416e13f1a851868ed95536358e7 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Sun, 8 Sep 2024 18:25:54 +0200 Subject: [PATCH 3/3] Small documentation improvements (#504) * Documentation: Fix typos * Docs: Use main branch links to source code The main branch evolves, and the documentation should evolve with it. Link to TypeScript interfaces and code samples on the main branch to avoid confusing users with outdated information. The documentation can still go out-of-date, of course. Mitigate that a bit by avoiding to link exact line numbers within a file, since they are most likely to change. * Docs: Improve consistency in prTitle documentation --- docs/config-file-options.md | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/config-file-options.md b/docs/config-file-options.md index 33e7aaac..fc560e34 100644 --- a/docs/config-file-options.md +++ b/docs/config-file-options.md @@ -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 { @@ -340,19 +340,19 @@ 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 { @@ -360,7 +360,15 @@ Default: `"[{{targetBranch}}] {{commitMessages}}"` } ``` -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` @@ -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** @@ -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` @@ -409,7 +417,7 @@ Default: `False` ```json { - "publishStatusCommentOnSuccess": false + "publishStatusCommentOnAbort": false } ``` @@ -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-` or `pr-` respectively. Default: `backport/{{targetBranch}}/{{refValues}}` @@ -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).