List of usage examples for org.eclipse.jgit.api Git rebase
public RebaseCommand rebase()
From source file:to.sauerkraut.krautadmin.core.Toolkit.java
License:Open Source License
public static boolean updateFromGit(final File repositoryDirectory, final URI repositoryUri) throws Exception { final String unexpectedExceptionText = "incremental plugin-update from git failed"; final String upstream = "refs/remotes/origin/master"; boolean hasUpdated = false; Git gitRepo = null; try {/*ww w .java 2 s . c o m*/ gitRepo = Git.open(repositoryDirectory); // first reset local changes gitRepo.reset().setMode(ResetCommand.ResetType.HARD).call(); LOG.info("starting incremental plugin-update from git..."); gitRepo.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).call(); final RebaseResult rebaseResult = gitRepo.rebase().setStrategy(MergeStrategy.THEIRS) .setUpstream(upstream).setUpstreamName(upstream).call(); final Status rebaseStatus = rebaseResult.getStatus(); if (rebaseStatus.isSuccessful()) { if (!(Status.UP_TO_DATE.equals(rebaseStatus))) { hasUpdated = true; } } else { throw new WTFException(unexpectedExceptionText); } if (hasUpdated) { LOG.info("incremental plugin-update from git successful"); } else { LOG.info("plugin-files are up-to-date"); } } finally { try { if (gitRepo != null) { gitRepo.close(); } } catch (Exception closex) { LOG.debug("closing git repo failed"); } } return hasUpdated; }