Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log error instead of crash on failed branch re-alignment #48

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -444,6 +445,9 @@ export class Manifest {
parseConfig(github, configFile, changesBranch, path, releaseAs),
parseReleasedVersions(github, manifestFile, changesBranch),
]);
if (manifestOptions.logger) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

@dgellow dgellow Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manifestOptions.logger is an optional logger instance to use. By default release-please relies on a global logger defined in src/util/logger.ts.

When CLI commands are run, setupLogger() is called to do some configuration.

In our case we are using release-please via fromManifest(), and pass the logger via the option. But I'm not convinced release-please correctly use the logger from the options all the time. It is safer to also set the global one to ensure a consistent logging behaviour.

setupLogger(manifestOptions.logger);
}
return new Manifest(
github,
targetBranch,
Expand Down Expand Up @@ -1292,7 +1296,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;
}
Expand Down
Loading