void cleanAndResetToMaster() throws IOException { try { git.reset().setMode(ResetCommand.ResetType.HARD).call(); checkout("master"); deleteBranch(BRANCH_AT_REVISION); deleteBranch(BRANCH_AT_HEAD); } catch (Exception e) { String currentBranch = git.getRepository().getBranch(); LOGGER.error("Error while trying to clean up config repository, CurrentBranch: {} \n : \n Message: {} \n StackTrace: {}", currentBranch, e.getMessage(), e.getStackTrace(), e); throw new RuntimeException(e); } }
private Ref resetHard(Git git, String label, String ref) { ResetCommand reset = git.reset(); reset.setRef(ref); reset.setMode(ResetType.HARD); try { Ref resetRef = reset.call(); if (resetRef != null) { this.logger.info( "Reset label " + label + " to version " + resetRef.getObjectId()); } return resetRef; } catch (Exception ex) { String message = "Could not reset to remote for " + label + " (current ref=" + ref + "), remote: " + git.getRepository().getConfig() .getString("remote", "origin", "url"); warn(message, ex); return null; } }
this.gitForPush.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD~1").call(); this.gitForPush.push().setForce(true).setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.gitForPush.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD~4").call(); this.gitForPush.push().setForce(true).setRemote("origin").setRefSpecs(this.masterRefSpec).call();
@Signature public Memory reset(Environment env, ArrayMemory settings) throws GitAPIException { ResetCommand reset = getWrappedObject().reset(); Memory mode = settings.valueOfIndex("mode"); if (mode.isNotNull()) { reset.setMode(ResetCommand.ResetType.valueOf(mode.toString())); } Memory ref = settings.valueOfIndex("ref"); if (ref.isNotNull()) { reset.setRef(ref.toString()); } reset.disableRefLog(settings.valueOfIndex("disableRefLog").toBoolean()); Memory paths = settings.valueOfIndex("paths"); if (paths.isNotNull()) { ForeachIterator iterator = paths.getNewIterator(env); if (iterator != null) { while (iterator.next()) { reset.addPath(iterator.getValue().toString()); } } else { reset.addPath(paths.toString()); } } Ref call = reset.call(); return GitUtils.valueOf(call); }
.call(); this.git.reset().setMode(ResetCommand.ResetType.HARD).setRef(REMOTE_NAME + "/" + this.branchName).call();
private void resetSoftToParent() throws IOException, GitAPIException, CheckoutConflictException { Ref ref = repo.exactRef(Constants.ORIG_HEAD); ObjectId orig_head = ref == null ? null : ref.getObjectId(); try (Git git = Git.wrap(repo)) { // we have already committed the cherry-picked commit. // what we need is to have changes introduced by this // commit to be on the index // resetting is a workaround git.reset().setMode(ResetType.SOFT) .setRef("HEAD~1").call(); //$NON-NLS-1$ } finally { // set ORIG_HEAD back to where we started because soft // reset moved it repo.writeOrigHead(orig_head); } }
private void reset() { try { git.reset().setMode(ResetCommand.ResetType.HARD).call(); } catch (Exception e) { log.error(e.getMessage(), e); } }
public void resetToRev(String revision) throws Exception { if(revision != null) { log.info("Resetting to sha {}", revision); git.reset().setMode(ResetType.HARD).setRef(revision).call(); } }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); try { for (final LazilyLoadedRepository repository : repositories) { Git.wrap(repository.get()).reset().setMode(HARD).call(); } } catch (GitAPIException e) { throw new ServletException(e); } }
public void resetHard() throws IOException { Git git = new Git(getJGitRepository()); try { git.reset().setMode(ResetCommand.ResetType.HARD).call(); } catch (GitAPIException e) { throw new IOException(e); } }
/** * Reset. * * @param path the path * @throws GitAPIException the exception */ public void reset(final String path) throws GitAPIException { if (!isUndefined()) { git.reset().addPath(path).call(); } }
private void resolveConflict(final String path) { try { git.reset().addPath(path).call(); git.checkout().addPath(path).call(); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } }
void reset(File project) { try (Git git = this.gitFactory.open(file(project))) { git.reset().setMode(ResetCommand.ResetType.HARD).call(); } catch (Exception e) { throw new IllegalStateException(e); } }
@Override public void resetHard(final Git repo, String newBase) throws GitAPIException { repo.reset().setMode(ResetCommand.ResetType.HARD).setRef(newBase).call(); }
public void cleanAndResetHard() throws NoWorkTreeException, GitAPIException { // enable updating by resetting the content of the repository this.clean(); // reset to the latest version ResetCommand reset = this.git.reset(); reset.setMode(ResetType.HARD); reset.call(); }
/** * @inheritDoc */ @Override public void resetHard(Git git, RevCommit commit){ try { git.reset().setMode(ResetCommand.ResetType.HARD).setRef(commit.getName()).call(); } catch (GitAPIException e) { throw new RuntimeException("Failed to hard reset to commit "+commit.getShortMessage(), e); } }
/** * Reset hard on HEAD. * * @throws GitAPIException */ public void rollback() throws GitAPIException { try (Git git = getGit()) { git.reset().setMode(ResetCommand.ResetType.HARD).setRef(HEAD).call(); } }
/** * Reset hard on HEAD. * * @throws GitAPIException */ public void rollback() throws GitAPIException { try (Git git = getGit()) { git.reset().setMode(ResetCommand.ResetType.HARD).setRef(HEAD).call(); } }
@Override public void rollback() { super.rollback(); try (Git git = repository.getGit()) { git.reset().setMode(ResetCommand.ResetType.HARD).setRef(Constants.HEAD).call(); } catch (GitAPIException ex) { MGMT_OP_LOGGER.failedToStoreConfiguration(ex, file.getName()); } }
private void gitUpdateFromOrigin() throws GitAPIException { git.fetch().setRemote("origin").call(); git.reset().setMode(ResetCommand.ResetType.HARD).setRef("origin/master").call(); this.contributors = getContributorsFromRepo(); }