Пример #1
0
 private boolean isMergedInto(Ref oldHead, AnyObjectId src) throws IOException {
   RevWalk revWalk = new RevWalk(db);
   ObjectId oldHeadObjectId = oldHead.getPeeledObjectId();
   if (oldHeadObjectId == null) oldHeadObjectId = oldHead.getObjectId();
   RevCommit oldHeadCommit = revWalk.lookupCommit(oldHeadObjectId);
   RevCommit srcCommit = revWalk.lookupCommit(src);
   return revWalk.isMergedInto(oldHeadCommit, srcCommit);
 }
Пример #2
0
  private boolean tag(
      HttpServletRequest request,
      HttpServletResponse response,
      Repository db,
      String commitId,
      String tagName,
      boolean isRoot)
      throws JSONException, URISyntaxException, ServletException {
    Git git = new Git(db);
    RevWalk walk = new RevWalk(db);
    try {
      ObjectId objectId = db.resolve(commitId);
      RevCommit revCommit = walk.lookupCommit(objectId);
      walk.parseBody(revCommit);

      GitTagHandlerV1.tag(git, revCommit, tagName);

      URI cloneLocation =
          BaseToCloneConverter.getCloneLocation(
              getURI(request), BaseToCloneConverter.COMMIT_REFRANGE);
      Commit commit = new Commit(cloneLocation, db, revCommit, null);
      JSONObject result = commit.toJSON();
      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 tagging.",
              e));
    } catch (GitAPIException e) {
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(
              IStatus.ERROR,
              HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
              "An error occured when tagging.",
              e));
    } catch (CoreException e) {
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(
              IStatus.ERROR,
              HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
              "An error occured when tagging.",
              e));
    } finally {
      walk.dispose();
    }
  }
Пример #3
0
  /**
   * Create a new commit.
   *
   * <p>The author and committer identities are stored using the current timestamp, after being
   * incremented by {@code secDelta}. The message body is empty.
   *
   * @param secDelta number of seconds to advance {@link #tick(int)} by.
   * @param tree the root tree for the commit.
   * @param parents zero or more parents of the commit.
   * @return the new commit.
   * @throws Exception
   */
  public RevCommit commit(final int secDelta, final RevTree tree, final RevCommit... parents)
      throws Exception {
    tick(secDelta);

    final org.eclipse.jgit.lib.CommitBuilder c;

    c = new org.eclipse.jgit.lib.CommitBuilder();
    c.setTreeId(tree);
    c.setParentIds(parents);
    c.setAuthor(new PersonIdent(author, new Date(now)));
    c.setCommitter(new PersonIdent(committer, new Date(now)));
    c.setMessage("");
    ObjectId id;
    try {
      id = inserter.insert(c);
      inserter.flush();
    } finally {
      inserter.release();
    }
    return pool.lookupCommit(id);
  }