async function handleMergeResult()

in ng-dev/pr/merge/index.ts [80:128]


  async function handleMergeResult(result: MergeResult, disableForceMergePrompt = false) {
    const {failure, status} = result;
    const canForciblyMerge = failure && failure.nonFatal;

    switch (status) {
      case MergeStatus.SUCCESS:
        info(green(`Successfully merged the pull request: #${prNumber}`));
        return true;
      case MergeStatus.DIRTY_WORKING_DIR:
        error(
          red(
            `Local working repository not clean. Please make sure there are ` +
              `no uncommitted changes.`,
          ),
        );
        return false;
      case MergeStatus.UNEXPECTED_SHALLOW_REPO:
        error(red(`Unable to perform merge in a local repository that is configured as shallow.`));
        error(red(`Please convert the repository to a complete one by syncing with upstream.`));
        error(red(`https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---unshallow`));
        return false;
      case MergeStatus.UNKNOWN_GIT_ERROR:
        error(
          red(
            'An unknown Git error has been thrown. Please check the output ' + 'above for details.',
          ),
        );
        return false;
      case MergeStatus.GITHUB_ERROR:
        error(red('An error related to interacting with Github has been discovered.'));
        error(failure!.message);
        return false;
      case MergeStatus.USER_ABORTED:
        info(`Merge of pull request has been aborted manually: #${prNumber}`);
        return true;
      case MergeStatus.FAILED:
        error(yellow(`Could not merge the specified pull request.`));
        error(red(failure!.message));
        if (canForciblyMerge && !disableForceMergePrompt) {
          info();
          info(yellow('The pull request above failed due to non-critical errors.'));
          info(yellow(`This error can be forcibly ignored if desired.`));
          return await promptAndPerformForceMerge();
        }
        return false;
      default:
        throw Error(`Unexpected merge result: ${status}`);
    }
  }