示例#1
0
 private List<String> getTags() {
   RevCommit commit = getCommit().getRevCommit();
   Repository repository = getCommit().getRepository();
   List<String> tags = new ArrayList<String>();
   for (Ref tag : repository.getTags().values())
     if (commit.equals(repository.peel(tag).getPeeledObjectId()))
       tags.add(Repository.shortenRefName(tag.getName()));
   Collections.sort(tags);
   return tags;
 }
  private boolean cherryPick(
      HttpServletRequest request,
      HttpServletResponse response,
      Repository db,
      String commitToCherryPick)
      throws ServletException, JSONException {
    RevWalk revWalk = new RevWalk(db);
    try {

      Ref headRef = db.getRef(Constants.HEAD);
      if (headRef == null)
        return statusHandler.handleRequest(
            request,
            response,
            new ServerStatus(
                IStatus.ERROR,
                HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "An error occured when cherry-picking.",
                null));
      RevCommit head = revWalk.parseCommit(headRef.getObjectId());

      ObjectId objectId = db.resolve(commitToCherryPick);
      Git git = new Git(db);
      CherryPickResult cherryPickResult = git.cherryPick().include(objectId).call();
      RevCommit newHead = cherryPickResult.getNewHead();

      JSONObject result = new JSONObject();
      result.put(GitConstants.KEY_RESULT, cherryPickResult.getStatus().name());
      result.put(GitConstants.KEY_HEAD_UPDATED, !head.equals(newHead));
      OrionServlet.writeJSONResponse(
          request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
      return true;
    } catch (IOException e) {
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(
              IStatus.ERROR,
              HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
              "An error occured when cherry-picking.",
              e));
    } catch (GitAPIException e) {
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(
              IStatus.ERROR,
              HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
              "An error occured when cherry-picking.",
              e));
    } finally {
      revWalk.release();
    }
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj instanceof GitCommitReference) {
     GitCommitReference other = (GitCommitReference) obj;
     return target.equals(other.target) && region.equals(other.region);
   }
   return false;
 }
示例#4
0
 @Override
 public boolean equals(Object object) {
   return super.equals(object) && targetCommit.equals(((ObjectLink) object).targetCommit);
 }