Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.ResetCommand


  @Argument(required = true, metaVar = "metaVar_name", usage = "usage_reset")
  private String commit;

  @Override
  protected void run() throws Exception {
    ResetCommand command = new Git(db).reset();
    command.setRef(commit);
    ResetType mode = null;
    if (soft)
      mode = selectMode(mode, ResetType.SOFT);
    if (mixed)
      mode = selectMode(mode, ResetType.MIXED);
    if (hard)
      mode = selectMode(mode, ResetType.HARD);
    if (mode == null)
      throw die("no reset mode set");
    command.setMode(mode);
    command.call();
  }
View Full Code Here


            .bind("Mixing {0} and {1} parameters is not allowed.", new Object[] { ProtocolConstants.KEY_PATH, GitConstants.KEY_TAG_COMMIT });
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
      }
      JSONArray paths = toReset.optJSONArray(ProtocolConstants.KEY_PATH);
      Git git = new Git(db);
      ResetCommand reset = git.reset().setRef(Constants.HEAD);
      if (paths != null) {
        for (int i = 0; i < paths.length(); i++) {
          reset.addPath(paths.getString(i));
        }
      } else {
        // path format is /file/{workspaceId}/{projectName}[/{path}]
        String projectRelativePath = path.removeFirstSegments(3).toString();
        if (projectRelativePath.isEmpty()) {
          String msg = "Path cannot be empty.";
          return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
        }
        reset.addPath(projectRelativePath);
      }
      try {
        reset.call();
      } catch (GitAPIException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), e));
      }
      return true;
    }
View Full Code Here

  private static GitCommand<?> prepareCommand(Repository repository,
      Collection<String> paths) {
    Git git = new Git(repository);
    if (hasHead(repository)) {
      ResetCommand resetCommand = git.reset();
      resetCommand.setRef(HEAD);
      for (String path : paths)
        resetCommand.addPath(getCommandPath(path));
      return resetCommand;
    } else {
      RmCommand rmCommand = git.rm();
      rmCommand.setCached(true);
      for (String path : paths)
View Full Code Here

    if (paths.isEmpty())
      return;

    try {
      Git git = new Git(currentRepository);
      ResetCommand reset = git.reset();
      for (String path : paths)
        reset.addPath(path);
      reset.call();
    } catch (GitAPIException e) {
      Activator.handleError(e.getMessage(), e, true);
    }
  }
View Full Code Here

    if (type == ResetType.HARD) {
      validProjects = ProjectUtil.getValidOpenProjects(repository);
      ResourceUtil.saveLocalHistory(repository);
    }

    ResetCommand reset = Git.wrap(repository).reset();
    reset.setMode(type);
    reset.setRef(refName);
    try {
      reset.call();
    } catch (GitAPIException e) {
      throw new TeamException(e.getLocalizedMessage(), e.getCause());
    }
    monitor.worked(1);
View Full Code Here

class GitPostReceiveHook implements PostReceiveHook{
 
    public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
        try {
            ResetCommand cmd = new Git(rp.getRepository()).reset();
            cmd.setMode(ResetType.HARD);
            cmd.setRef("master");
            cmd.call();
           
            WfUtil.deployAllToEngine();
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            e.printStackTrace(new PrintWriter(sw));
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.ResetCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.