Java Code Examples for org.eclipse.jgit.api.ResetCommand#setMode()
The following examples show how to use
org.eclipse.jgit.api.ResetCommand#setMode() .
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: DevicesGit.java From Flashtool with GNU General Public License v3.0 | 6 votes |
public static void pullRepository() { try { logger.info("Scanning devices folder for changes."); git.add().addFilepattern(".").call(); Status status = git.status().call(); if (status.getChanged().size()>0 || status.getAdded().size()>0 || status.getModified().size()>0) { logger.info("Changes have been found. Doing a hard reset (removing user modifications)."); ResetCommand reset = git.reset(); reset.setMode(ResetType.HARD); reset.setRef(Constants.HEAD); reset.call(); } logger.info("Pulling changes from github."); git.pull().call(); } catch (NoHeadException e) { logger.info("Pull failed. Trying to clone repository instead"); closeRepository(); cloneRepository(); } catch (Exception e1) { closeRepository(); } }
Example 2
Source File: JGitEnvironmentRepository.java From spring-cloud-config with Apache License 2.0 | 6 votes |
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; } }
Example 3
Source File: JGitOperator.java From verigreen with Apache License 2.0 | 5 votes |
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); } }