backport
Version:
A CLI tool that automates the process of backporting commits
32 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BackportError = void 0;
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 'message-only-exception':
return errorContext.message;
}
}
class BackportError extends Error {
constructor(errorContextOrString) {
const errorContext = typeof errorContextOrString === 'string'
? { code: 'message-only-exception', message: errorContextOrString }
: errorContextOrString;
const message = getMessage(errorContext);
super(message);
Error.captureStackTrace(this, BackportError);
this.name = 'BackportError';
this.message = message;
this.errorContext = errorContext;
}
}
exports.BackportError = BackportError;
//# sourceMappingURL=BackportError.js.map