org.eclipse.jgit.api.errors.CheckoutConflictException Java Examples
The following examples show how to use
org.eclipse.jgit.api.errors.CheckoutConflictException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitCommitHandlerV1.java From orion.server with Eclipse Public License 1.0 | 6 votes |
private boolean workaroundBug356918(HttpServletRequest request, HttpServletResponse response, Exception e) throws ServletException, JSONException { if (e instanceof CheckoutConflictException) { JSONObject result = new JSONObject(); result.put(GitConstants.KEY_RESULT, MergeStatus.FAILED.name()); Map<String, MergeFailureReason> failingPaths = new HashMap<String, MergeFailureReason>(); String[] files = e.getMessage().split("\n"); //$NON-NLS-1$ for (int i = 1; i < files.length; i++) { // TODO: this is not always true, but it's a temporary // workaround failingPaths.put(files[i], MergeFailureReason.DIRTY_WORKTREE); } result.put(GitConstants.KEY_FAILING_PATHS, failingPaths); try { OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT); return true; } catch (IOException e1) { e = e1; } } return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occurred when merging.", e.getCause())); }
Example #2
Source File: JGitEnvironmentRepositoryConcurrencyTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Override public Ref call() throws GitAPIException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException { try { Thread.sleep(250); } catch (InterruptedException e) { e.printStackTrace(); } return super.call(); }
Example #3
Source File: MergeTask.java From ant-git-tasks with Apache License 2.0 | 5 votes |
@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); } }
Example #4
Source File: GitManagerImpl.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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; } }
Example #5
Source File: MavenIntegrationTest.java From gitflow-incremental-builder with MIT License | 4 votes |
private void checkoutDevelop() throws GitAPIException, CheckoutConflictException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException { Git git = localRepoMock.getGit(); git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD").call(); git.checkout().setName("develop").call(); }
Example #6
Source File: GitControl.java From juneau with Apache License 2.0 | 4 votes |
public void branch(String name) throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException, GitAPIException { git.checkout().setName(name).setStartPoint("origin/".concat(name)).call(); }