angular/dev-infra/pr/merge/failures.ts
Paul Gschwendtner 318e9372c9 feat(dev-infra): move merge script over from components repo (#37138)
Moves the merge script from the components repository over
to the shared dev-infra package. The merge script has been
orginally built for all Angular repositories, but we just
kept it in the components repo temporarily to test it.

Since everything went well on the components side, we now
move the script over and integrate it into the dev-infra package.

PR Close #37138
2020-05-18 11:50:07 -07:00

80 lines
2.4 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Class that can be used to describe pull request failures. A failure
* is described through a human-readable message and a flag indicating
* whether it is non-fatal or not.
*/
export class PullRequestFailure {
constructor(
/** Human-readable message for the failure */
public message: string,
/** Whether the failure is non-fatal and can be forcibly ignored. */
public nonFatal = false) {}
static claUnsigned() {
return new this(`CLA has not been signed. Please make sure the PR author has signed the CLA.`);
}
static failingCiJobs() {
return new this(`Failing CI jobs.`, true);
}
static pendingCiJobs() {
return new this(`Pending CI jobs.`, true);
}
static notMergeReady() {
return new this(`Not marked as merge ready.`);
}
static noTargetLabel() {
return new this(`No target branch could be determined. Please ensure a target label is set.`);
}
static mismatchingTargetBranch(allowedBranches: string[]) {
return new this(
`Pull request is set to wrong base branch. Please update the PR in the Github UI ` +
`to one of the following branches: ${allowedBranches.join(', ')}.`);
}
static unsatisfiedBaseSha() {
return new this(
`Pull request has not been rebased recently and could be bypassing CI checks. ` +
`Please rebase the PR.`);
}
static mergeConflicts(failedBranches: string[]) {
return new this(
`Could not merge pull request into the following branches due to merge ` +
`conflicts: ${
failedBranches.join(', ')}. Please rebase the PR or update the target label.`);
}
static unknownMergeError() {
return new this(`Unknown merge error occurred. Please see console output above for debugging.`);
}
static unableToFixupCommitMessageSquashOnly() {
return new this(
`Unable to fixup commit message of pull request. Commit message can only be ` +
`modified if the PR is merged using squash.`);
}
static notFound() {
return new this(`Pull request could not be found upstream.`);
}
static insufficientPermissionsToMerge() {
return new this(
`Insufficient Github API permissions to merge pull request. Please ` +
`ensure that your auth token has write access.`);
}
}