Java 类org.eclipse.jgit.api.errors.CheckoutConflictException 实例源码

项目:commitmining-tools    文件:RepositoryFileWalker.java   
/**
 * Switch to the main branch and delete the temporary branch.
 *
 * @throws GitAPIException
 * @throws RefAlreadyExistsException
 * @throws RefNotFoundException
 * @throws InvalidRefNameException
 * @throws CheckoutConflictException
 * @throws NotMergedException
 * @throws CannotDeleteCurrentBranchException
 */
private void switchToMainAndDeleteFrom(final String tempBranch)
        throws GitAPIException, RefAlreadyExistsException,
        RefNotFoundException, InvalidRefNameException,
        CheckoutConflictException, NotMergedException,
        CannotDeleteCurrentBranchException {
    try {
        repository.reset().setMode(ResetType.HARD).call();
    } finally {
        try {
            repository.checkout().setCreateBranch(false)
            .setName(mainBranchName).setForce(true).call();
        } finally {
            try {
                repository.reset().setMode(ResetType.HARD).call();
            } finally {
                repository.branchDelete().setForce(true)
                .setBranchNames(tempBranch).call();
            }
        }
    }
}
项目:github-backup-java    文件:CreateOrphanBranchCommand.java   
@Override
public Ref call() throws GitAPIException, RefNotFoundException,
    CheckoutConflictException, InvalidRefNameException,
    RefAlreadyExistsException
{
    this.checkCallable();
    try {
        this.processOptions();
        this.checkoutStartPoint();
        RefUpdate update = this.getRepository().updateRef(Constants.HEAD);
        Result r = update.link(this.getBranchName());
        if (EnumSet.of(Result.NEW, Result.FORCED).contains(r) == false) {
            throw new JGitInternalException(MessageFormat.format(
                JGitText.get().checkoutUnexpectedResult, r.name()));
        }
        this.setCallable(false);
        return this.getRepository().getRef(Constants.HEAD);
    }
    catch (IOException e) {
        throw new JGitInternalException(e.getMessage(), e);
    }
}
项目:github-backup-java    文件:CreateOrphanBranchCommand.java   
protected void checkout(ObjectId fromId) throws GitAPIException,
    CheckoutConflictException, IOException
{
    RevWalk rw = new RevWalk(this.getRepository());
    try {
        Ref headRef = this.repo.getRef(Constants.HEAD);
        AnyObjectId headId = headRef.getObjectId();
        RevCommit headCommit = headId == null ? null : rw.parseCommit(headId);
        RevTree headTree = headCommit == null ? null : headCommit.getTree();
        RevCommit from = rw.parseCommit(fromId);
        this.checkout(headTree, from.getTree());
    }
    finally {
        rw.release();
    }
}
项目:github-backup-java    文件:CreateOrphanBranchCommand.java   
protected void checkout(RevTree headTree, RevTree fromTree)
    throws GitAPIException, CheckoutConflictException, IOException
{
    // DirCacheCheckout free lock of DirCache
    DirCacheCheckout dco =
        new DirCacheCheckout(this.getRepository(), headTree, this.repo
            .lockDirCache(), fromTree);
    dco.setFailOnConflict(true);
    try {
        dco.checkout();
        this.toBeDeleted = dco.getToBeDeleted();
    }
    catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
        this.conflicts = dco.getConflicts();
        throw new CheckoutConflictException(dco.getConflicts(), e);
    }
}
项目:rebazer    文件:RebaseService.java   
private void resetAndRemoveUntrackedFiles( final Git repository )
        throws GitAPIException, CheckoutConflictException {
    repository.clean() //
            .setCleanDirectories( true ) //
            .setForce( true ) //
            .setIgnore( false ) //
            .call(); //

    repository.reset() //
            .setMode( ResetType.HARD ) //
            .call(); //
}
项目:oxygen-git-plugin    文件:PushPullController.java   
/**
 * Pull failed because there are uncommitted files that would be in conflict
 * after the pull.
 * 
 * @param e Exception.
 */
protected void showPullFailedBecauseofConflict(CheckoutConflictException e) {
  new PullWithConflictsDialog(
      translator.getTranslation(Tags.PULL_STATUS), 
      e.getConflictingPaths(), 
      translator.getTranslation(Tags.PULL_CHECKOUT_CONFLICT_MESSAGE));
}
项目:ant-git-tasks    文件:MergeTask.java   
@Override
public void doExecute() {
        try {
                MergeCommand mergeCommand = git.merge().setSquash(squash);
                mergeCommand.include(mergeCommand.getRepository().getRef(branchname));

                setupCredentials(mergeCommand);

                MergeResult mergeResult = null;
                try {
                        mergeResult = mergeCommand.call();
                } catch (CheckoutConflictException conflicts) {
                        throw new BuildException(String.format("%s - Checkout conflicts: %s", MESSAGE_MERGE_FAILED, conflicts.getConflictingPaths()));
                }

                if (!mergeResult.getMergeStatus().isSuccessful()) {

                        if (mergeResult.getCheckoutConflicts() != null && mergeResult.getCheckoutConflicts().size() > 0) {
                                throw new BuildException(String.format("%s - Checkout conflicts: %s", MESSAGE_MERGE_FAILED, mergeResult.getCheckoutConflicts()));
                        }

                        if (mergeResult.getFailingPaths() != null && mergeResult.getFailingPaths().size() > 0) {
                                throw new BuildException(String.format("%s - Failing paths: %s", MESSAGE_MERGE_FAILED, mergeResult.getFailingPaths()));
                        }

                        throw new BuildException(String.format(MESSAGE_MERGE_FAILED_WITH_STATUS, mergeResult.getMergeStatus().name()));
                }
        } catch (Exception e) {
                throw new GitBuildException(String.format(MESSAGE_MERGE_FAILED_WITH_URI, getUri()), e);
        }
}
项目:github-backup-java    文件:CreateOrphanBranchCommand.java   
protected void checkoutStartPoint() throws GitAPIException,
    RefNotFoundException, CheckoutConflictException, IOException
{
    ObjectId sp = this.getStartPoint();
    if (sp != null) {
        this.checkout(sp);
    }
}
项目:WebIDE-Backend    文件:GitManagerImpl.java   
@Override
public CheckoutResponse checkout(Workspace ws, String name, String startPoint) throws GitAPIException, IOException, GitOperationException {
    Repository repository = getRepository(ws.getSpaceKey());


    try (Git git = Git.wrap(repository)) {
        CheckoutCommand command = git.checkout().setName(name);

        if (isRemoteBranch(ws, name)) {
            throw new GitOperationException("Remote branch must be checkout as new local branch");
        }

        if (StringUtils.isNotEmpty(startPoint)) {
            command.setStartPoint(startPoint);
            command.setCreateBranch(true);
        }

        try {
            command.call();
        } catch (CheckoutConflictException e) {
            // Ignore
        }

        CheckoutResult result = command.getResult();
        CheckoutResult.Status s = result.getStatus();

        CheckoutResponse.Status status = CheckoutResponse.Status.OK;
        if (s == CheckoutResult.Status.CONFLICTS) {
            status = CheckoutResponse.Status.CONFLICTS;
        } else if (s == CheckoutResult.Status.ERROR) {
            status = CheckoutResponse.Status.ERROR;
        } else if (s == CheckoutResult.Status.NONDELETED) {
            status = CheckoutResponse.Status.NONDELETED;
        } else if (s == CheckoutResult.Status.NOT_TRIED) {
            status = CheckoutResponse.Status.NOT_TRIED;
        }

        CheckoutResponse response = new CheckoutResponse();
        response.setStatus(status);
        response.setConflictList(result.getConflictList());
        response.setModifiedList(result.getModifiedList());
        response.setRemovedList(result.getRemovedList());
        response.setUndeletedList(result.getUndeletedList());

        publisher.publishEvent(new GitCheckoutEvent(ws, repository.getBranch()));

        return response;
    }

}
项目:GitDirStat    文件:GitRepository.java   
public void applyFilter(Collection<CommitRange> commitRanges,
        IndexFilter indexFilter) throws IOException,
        CheckoutConflictException, GitAPIException {
    applyFilter(commitRanges, indexFilter, NullProgressListener.INSTANCE);
}
项目:GitDirStat    文件:GitRepository.java   
public void applyFilter(Collection<CommitRange> commitRanges,
        IndexFilter indexFilter) throws IOException,
        CheckoutConflictException, GitAPIException {
    applyFilter(commitRanges, indexFilter, NullProgressListener.INSTANCE);
}