Example #1
0
  @Override
  public PullResponse pull(PullRequest request) throws GitException, UnauthorizedException {
    String remoteUri = getRemoteUri(request.getRemote());

    PullCommand pullCommand = nativeGit.createPullCommand();
    pullCommand
        .setRemote(request.getRemote())
        .setRefSpec(request.getRefSpec())
        .setAuthor(getLocalCommitter())
        .setRemoteUri(remoteUri)
        .setTimeout(request.getTimeout());

    try {
      executeRemoteCommand(pullCommand);
    } catch (GitException exception) {
      if (noInitCommitWhenPullErrorPattern.matcher(exception.getMessage()).find()) {
        throw new GitException(
            exception.getMessage(), ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED);
      } else if ("Unable get private ssh key".equals(exception.getMessage())) {
        throw new GitException(exception.getMessage(), ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY);
      } else if (("Auto-merging file\nCONFLICT (content): Merge conflict in file\n"
              + "Automatic merge failed; fix conflicts and then commit the result.\n")
          .equals(exception.getMessage())) {
        throw new GitException(exception.getMessage(), ErrorCodes.MERGE_CONFLICT);
      } else {
        throw exception;
      }
    }

    return pullCommand.getPullResponse();
  }
  @Override
  public PullResponse pull(PullRequest request) throws GitException, UnauthorizedException {
    ensureExistenceRepoRootInWorkingDirectory();
    String remoteUri = getRemoteUri(request.getRemote());

    PullCommand pullCommand = nativeGit.createPullCommand();
    pullCommand
        .setRemote(request.getRemote())
        .setRefSpec(request.getRefSpec())
        .setAuthor(getLocalCommitter())
        .setRemoteUri(remoteUri)
        .setTimeout(request.getTimeout());

    executeRemoteCommand(pullCommand);

    return pullCommand.getPullResponse();
  }