org.eclipse.jgit.api.RebaseCommand Java Examples
The following examples show how to use
org.eclipse.jgit.api.RebaseCommand.
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: LocalGitProvider.java From judgels with GNU General Public License v2.0 | 6 votes |
@Override public boolean rebase(List<String> rootDirPath) { File root = new File(fileSystemProvider.getURL(rootDirPath)); try { Repository repo = FileRepositoryBuilder.create(new File(root, ".git")); RebaseResult result = new Git(repo).rebase().setUpstream("origin/master").call(); if (result.getStatus() == RebaseResult.Status.STOPPED) { new Git(repo).rebase().setOperation(RebaseCommand.Operation.ABORT).call(); repo.close(); return false; } repo.close(); return true; } catch (IOException | GitAPIException e) { throw new RuntimeException(e); } }
Example #2
Source File: SquashActionHandler.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public RebaseResponse process(Repository repository, String message) throws GitAPIException, IOException { try (Git git = Git.wrap(repository)) { git.commit() .setMessage(stripCommentLines(message)) .setAmend(true).setNoVerify(true).call(); getRebaseFile(repository, MESSAGE_SQUASH).delete(); getRebaseFile(repository, MESSAGE_FIXUP).delete(); createFile(repository, MESSAGE, message); RebaseResult result = git.rebase() .setOperation(RebaseCommand.Operation.SKIP) .runInteractively(handler) .call(); return new RebaseResponse(result); } }
Example #3
Source File: EditActionHandler.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public RebaseResponse process(Repository repository, String message) throws GitAPIException { try (Git git = Git.wrap(repository)) { git.commit() .setAll(true) .setAmend(true) .setNoVerify(true) .setMessage(message) .call(); RebaseResult result = git.rebase() .setOperation(RebaseCommand.Operation.CONTINUE) .runInteractively(handler) .call(); // 如果 conflict and edit,amend 后 continue 会返回 NOTHING_TO_COMMIT // so skip this commit if (result.getStatus().equals(RebaseResult.Status.NOTHING_TO_COMMIT)) { result = git.rebase().setOperation(RebaseCommand.Operation.SKIP).call(); } return new RebaseResponse(result); } }
Example #4
Source File: RewordActionHandler.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public RebaseResponse process(Repository repository, String message) throws GitAPIException, IOException { try (Git git = Git.wrap(repository)) { git.commit() .setMessage(message) .setAmend(true) .setNoVerify(true) .call(); RebaseResult result = git.rebase() .setOperation(RebaseCommand.Operation.SKIP) .runInteractively(handler) .call(); return new RebaseResponse(result); } }
Example #5
Source File: JGitOperator.java From verigreen with Apache License 2.0 | 6 votes |
@Override public boolean rebase(String upStreamBranchName) { RebaseCommand command = _git.rebase(); RebaseResult result = null; try { command.setUpstream(upStreamBranchName); result = command.call(); // if there are merge conflicts (rebase interactive) - reset the repository if (!result.getStatus().isSuccessful()) { _git.rebase().setOperation(Operation.ABORT).call(); } } catch (Throwable e) { throw new RuntimeException(String.format( "Failed to rebase with upstream [%s]", upStreamBranchName), e); } return result.getStatus().isSuccessful(); }