CommitsApi.java 33.15 KiB
package org.gitlab4j.api;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Comment;
import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CommitAction;
import org.gitlab4j.api.models.CommitAction.Action;
import org.gitlab4j.api.models.CommitPayload;
import org.gitlab4j.api.models.CommitRef;
import org.gitlab4j.api.models.CommitRef.RefType;
import org.gitlab4j.api.models.CommitStatus;
import org.gitlab4j.api.models.CommitStatusFilter;
import org.gitlab4j.api.models.Diff;
import org.gitlab4j.api.utils.ISO8601;
/**
 * This class implements the client side API for the GitLab commits calls.
 * See <a href="https://docs.gitlab.com/ce/api/commits.html">Commits API at GitLab</a> for more information.
public class CommitsApi extends AbstractApi {
    public CommitsApi(GitLabApi gitLabApi) {
        super(gitLabApi);
    /**
     * Get a list of repository commits in a project.
     * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre>
     * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
     * @return a list containing the commits for the specified project ID
     * @throws GitLabApiException GitLabApiException if any exception occurs during execution
    public List<Commit> getCommits(Object projectIdOrPath) throws GitLabApiException {
        return (getCommits(projectIdOrPath, null, null, null, getDefaultPerPage()).all());
    /**
     * Get a list of repository commits in a project.
     * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre>
     * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
     * @param page the page to get
     * @param perPage the number of commits per page
     * @return a list containing the commits for the specified project ID
     * @throws GitLabApiException GitLabApiException if any exception occurs during execution
    public List<Commit> getCommits(Object projectIdOrPath, int page, int perPage) throws GitLabApiException {
        return (getCommits(projectIdOrPath, null, null, null, page, perPage));
    /**
     * Get a Pager of repository commits in a project.
     * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre>
     * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
     * @param itemsPerPage the number of Commit instances that will be fetched per page
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
* @return a Pager containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public Pager<Commit> getCommits(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (getCommits(projectIdOrPath, null, null, null, itemsPerPage)); } /** * Get a Stream of repository commits in a project. * * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @return a Stream containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public Stream<Commit> getCommitStream(Object projectIdOrPath) throws GitLabApiException { return (getCommits(projectIdOrPath, null, null, null, getDefaultPerPage()).stream()); } /** * Get a list of repository commits in a project. * * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param ref the name of a repository branch or tag or if not given the default branch * @param since only commits after or on this date will be returned * @param until only commits before or on this date will be returned * @param path the path to file of a project * @return a list containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List<Commit> getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path) throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, path, getDefaultPerPage()).all()); } /** * Get a list of file commits in a project * * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits?path=:file_path</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param ref the name of a repository branch or tag or if not given the default branch * @param path the path to file of a project * @return a list containing the commits for the specified project ID and file * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List<Commit> getCommits(Object projectIdOrPath, String ref, String path) throws GitLabApiException { return (getCommits(projectIdOrPath, ref, null, null, path, getDefaultPerPage()).all()); } /** * Get a list of repository commits in a project. * * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits</code></pre> * * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param ref the name of a repository branch or tag or if not given the default branch * @param since only commits after or on this date will be returned * @param until only commits before or on this date will be returned * @return a list containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List<Commit> getCommits(Object projectIdOrPath, String ref, Date since, Date until) throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, null, getDefaultPerPage()).all()); } /** * Get a list of repository commits in a project.