UNPKG

backport

Version:

A CLI tool that automates the process of backporting commits

56 lines 2.48 kB
function getMessage(errorContext) { switch (errorContext.code) { case 'merge-conflict-exception': { return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`; } case 'no-branches-exception': { return 'There are no branches to backport to. Aborting.'; } case 'abort-conflict-resolution-exception': { return 'Conflict resolution was aborted by the user'; } case 'invalid-branch-exception': { return `The branch "${errorContext.branchName}" does not exist`; } case 'pr-not-found-exception': { return `The PR #${errorContext.pullNumber} does not exist`; } case 'pr-not-merged-exception': { return `The PR #${errorContext.pullNumber} is not merged`; } case 'commit-not-found-exception': { return `No commit found on branch "${errorContext.sourceBranch}" with sha "${errorContext.sha}"`; } case 'no-commits-found-exception': case 'invalid-credentials-exception': case 'config-error-exception': case 'pr-creation-exception': case 'cherrypick-exception': case 'clone-exception': case 'buffer-overflow-exception': case 'github-api-exception': case 'auto-merge-not-available-exception': { return errorContext.message; } case 'repo-not-found-exception': { return `Error pushing to https://github.com/${errorContext.repoForkOwner}/${errorContext.repoName}. Repository does not exist. Either fork the repository (https://github.com/${errorContext.repoOwner}/${errorContext.repoName}) or disable fork mode via "--no-fork".\nRead more about fork mode in the docs: https://github.com/sorenlouv/backport/blob/main/docs/configuration.md#fork`; } case 'branch-not-found-exception': { return `The branch "${errorContext.branchName}" is invalid or doesn't exist`; } case 'max-retries-exception': { return 'Maximum number of retries exceeded'; } } } export class BackportError extends Error { errorContext; constructor(errorContext) { const message = getMessage(errorContext); super(message); this.name = 'BackportError'; this.message = message; this.errorContext = errorContext; } } //# sourceMappingURL=backport-error.js.map