Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.Git.reset()


            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();
                    }
                }
View Full Code Here


        return;
      }
    }

    // rewind master by two commits
    git.reset().setRef("HEAD~2").setMode(ResetType.HARD).call();

    // commit a change on this detached HEAD
    file = new File(local, "REWINDCHK");
    os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
    w = new BufferedWriter(os);
View Full Code Here

    git.commit().setMessage("c2").call();
    deleteTrashFile("f/g");
    deleteTrashFile("f");

    // The actual test
    git.reset().setMode(ResetType.HARD).setRef(id1.getName()).call();
    assertIndex(mkmap("x", "x"));
  }

  /**
   * Test first checkout in a repo
View Full Code Here

        case HARD:
        case SOFT:
          Git git = new Git(db);
          // "git reset --{type} HEAD ."
          try {
            git.reset().setMode(type).setRef(ref).call();
          } catch (GitAPIException e) {
            statusHandler.handleRequest(request, response,
                new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(), e));
          }
          return true;
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 {
View Full Code Here

            return;
        }

        try {
            final Git git = new Git(repository);
            git.reset().setRef(commit.getName()).setMode(ResetType.HARD).call();
            // Commit changes
            commitAllChanges(message);
            LOGGER.info("Reset of last " + (noOfCommitsToRevert + 1)
                    + " successful.");
        }
View Full Code Here

        if (repo.resolve(tag) != null) {
            log.info("Deleting tag: " + tag);
            git.tagDelete().setTags(tag).call();
        }

        git.reset().setMode(ResetCommand.ResetType.HARD).setRef(sha).call();

        if (!transactionFile.delete()) {
            log.error("Failed to delete transaction file: " + transactionFile);
        }
    }
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 {
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

TOP
Copyright © 2018 www.massapi.com. 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.