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); } }
ResetCommand reset = new Git(repository).reset(); reset.setRef(Constants.HEAD); reset.addPath("foo.txt"); reset.call();
public void reset(String refToResetTo) { ResetCommand command = _git.reset(); command.setRef(refToResetTo); command.setMode(ResetType.HARD); try { command.call(); } catch (Throwable e) { throw new RuntimeException(String.format("Failed to reset to [%s]", refToResetTo), 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 resetHard(final Git repo, String newBase) throws GitAPIException { repo.reset().setMode(ResetCommand.ResetType.HARD).setRef(newBase).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()); } }
public void setRevisionTo(String ref) throws GitAPIException { this.clean(); // reset repository to the desired reference ResetCommand reset = this.git.reset(); reset.setMode(ResetType.HARD); reset.setRef(ref); reset.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()); } }
protected void setRevisionTo(String ref) throws GitAPIException { git.clean().setForce(true).setCleanDirectories(true).call(); git.reset() .setMode(ResetCommand.ResetType.HARD) .setRef(ref) .call(); LOGGER.debug("Switched to commit {}", ref); }
public File operateOn(Repository repo) throws Exception { Git git = new Git(repo); if (repo.getAllRefs().containsKey("refs/heads/master")) { git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD").call(); for (String path : git.status().call().getUntracked()) { new File(repo.getWorkTree(), path).delete(); } } return ZipWriter.addDirectoryContentsToJar(repo.getWorkTree(), ".git"); } });
public String hardReset() throws IOException { final Repository repo = this.openRepository(); final Git git = new Git(repo); if (repo.getRepositoryState().canResetHead()) { try { return git.reset().setMode(ResetType.HARD).setRef("master").call().getObjectId().name(); } catch (CheckoutConflictException e) { throw new IOException("not able to perform a hard reset", e); } catch (GitAPIException e) { throw new IOException("problem executing reset command", e); } } return ""; }
private void resetToBranch() throws IOException, GitAPIException { Ref master = repository.getRef(Constants.R_HEADS + "master"); if (master != null) { Git git = new Git(repository); git.reset().setMode(ResetType.HARD).setRef(master.getName()).call(); } }
private void gitUpdateFromOrigin() throws GitAPIException { git.fetch().setRemote("origin").call(); git.reset().setMode(ResetCommand.ResetType.HARD).setRef("origin/master").call(); this.contributors = getContributorsFromRepo(); }