From 1930abf574cb545608b7985ee65100bbbd00d611 Mon Sep 17 00:00:00 2001 From: Samuel El-Borai Date: Mon, 2 Oct 2023 21:18:29 +0200 Subject: [PATCH 1/3] fix: do not crash if branch cannot be re-aligned, but log error --- src/manifest.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/manifest.ts b/src/manifest.ts index 24a39c546..f3fcd8cf0 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -1292,7 +1292,11 @@ export class Manifest { // try to re-align branches to ensure the next release pull request won't face git conflicts. In case of // inconsistencies releases are still created but the command fails and won't force a re-alignment between a PR // ref branch and base branch. - await this.alignPullRequestsChangesBranch(pullRequests); + try { + await this.alignPullRequestsChangesBranch(pullRequests); + } catch (err) { + this.logger.error(err as {}); + } return createdReleases; } From 490b1d2a7ad4503a3285d8268808e6ac824a27f5 Mon Sep 17 00:00:00 2001 From: Samuel El-Borai Date: Mon, 2 Oct 2023 21:22:08 +0200 Subject: [PATCH 2/3] feat: ensure the global logger is set if one is passed to the manifest factory --- src/manifest.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/manifest.ts b/src/manifest.ts index f3fcd8cf0..e2f7545bc 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -50,6 +50,7 @@ import { } from './util/pull-request-overflow-handler'; import {signoffCommitMessage} from './util/signoff-commit-message'; import {CommitExclude} from './util/commit-exclude'; +import {setupLogger} from 'code-suggester/build/src/logger'; type ExtraJsonFile = { type: 'json'; @@ -444,6 +445,9 @@ export class Manifest { parseConfig(github, configFile, changesBranch, path, releaseAs), parseReleasedVersions(github, manifestFile, changesBranch), ]); + if (manifestOptions.logger) { + setupLogger(manifestOptions.logger); + } return new Manifest( github, targetBranch, From d8c6e452e5714c21045f3d8c8ad3040a1c1b5aa5 Mon Sep 17 00:00:00 2001 From: Samuel El-Borai Date: Mon, 2 Oct 2023 21:35:55 +0200 Subject: [PATCH 3/3] fix: test --- __snapshots__/manifest.ts.js | 5 ----- test/manifest.ts | 11 ++--------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/__snapshots__/manifest.ts.js b/__snapshots__/manifest.ts.js index 8b4589a62..41235aca2 100644 --- a/__snapshots__/manifest.ts.js +++ b/__snapshots__/manifest.ts.js @@ -225,8 +225,3 @@ exports['Manifest buildPullRequests should warn end user via PR comment if versi To set a custom version be sure to use the [semantic versioning format](https://devhints.io/semver), e.g \`1.2.3\`. ` - -exports['Manifest createReleases should throw when release branch is missing and changes-branch not in synced with target-branch 1'] = ` -Errors when aligning pull requests branches: - - Branch 'next' cannot be safely re-aligned with 'main', and will likely result in git conflicts when the next release PR is created. Hint: compare branches 'release-please--branches--main--changes--next', 'next', and 'main' for inconsistencies -` diff --git a/test/manifest.ts b/test/manifest.ts index 3b10726d4..26bedc6be 100644 --- a/test/manifest.ts +++ b/test/manifest.ts @@ -8637,7 +8637,7 @@ version = "3.0.0" sinon.assert.calledOnce(unlockBranchStub); }); - it('should throw when release branch is missing and changes-branch not in synced with target-branch', async () => { + it('should not throw when release branch is missing and changes-branch not in synced with target-branch', async () => { mockPullRequests( github, [], @@ -8737,14 +8737,7 @@ version = "3.0.0" } ); - let err: unknown; - try { - await manifest.createReleases(); - } catch (e) { - err = e; - } - expect(err).to.be.instanceOf(Error); - snapshot((err).message); + await manifest.createReleases(); // releases are still created sinon.assert.calledOnce(commentStub);