コード例 #1
0
  /**
   * Helper method extracting the StashRef for the stash commit rev
   *
   * @param git Git handler object
   * @param stashRev Git commit name
   * @return StashRef wrapper object or <code>null</code> if the given commit is not present in the
   *     stash
   * @throws InvalidRefNameException
   * @throws GitAPIException
   */
  protected StashRef getStashRef(Git git, String stashRev)
      throws InvalidRefNameException, GitAPIException {

    if (stashRev == null) return null;

    StashListCommand stashList = git.stashList();
    Collection<RevCommit> stashedRefsCollection = stashList.call();

    int k = 0;
    for (RevCommit rev : stashedRefsCollection)
      if (stashRev.equals(rev.getName())) return new StashRef(k);
      else ++k;

    return null;
  }
コード例 #2
0
  @Override
  protected boolean handleGet(RequestInfo requestInfo) throws ServletException {

    HttpServletRequest request = requestInfo.request;
    HttpServletResponse response = requestInfo.response;
    Repository db = requestInfo.db;

    int page =
        request.getParameter("page") != null
            ? new Integer(request.getParameter("page")).intValue()
            : 1; //$NON-NLS-1$ //$NON-NLS-2$
    int pageSize =
        request.getParameter("pageSize") != null
            ? new Integer(request.getParameter("pageSize")).intValue()
            : PAGE_SIZE; //$NON-NLS-1$ //$NON-NLS-2$
    String messageFilter = request.getParameter("filter"); // $NON-NLS-1$
    try {

      URI baseLocation = getURI(request);
      URI cloneLocation =
          BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.COMMIT);

      Git git = new Git(db);
      StashListCommand stashList = git.stashList();
      Collection<RevCommit> stashedRefsCollection = stashList.call();

      StashPage stashPage =
          new StashPage(cloneLocation, db, stashedRefsCollection, page, pageSize, messageFilter);
      OrionServlet.writeJSONResponse(request, response, stashPage.toJSON());
      return true;

    } catch (Exception ex) {
      String msg = "An error occured for stash command.";
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, ex));
    }
  }
コード例 #3
0
 /**
  * Helper method returning whether the stash is empty or not
  *
  * @param git Git handler object
  * @return <code>true</code> iff the git stash is empty
  * @throws InvalidRefNameException
  * @throws GitAPIException
  */
 protected boolean isStashEmpty(Git git) throws InvalidRefNameException, GitAPIException {
   StashListCommand stashList = git.stashList();
   Collection<RevCommit> stashedRefsCollection = stashList.call();
   return stashedRefsCollection.isEmpty();
 }