Class CommitsApi

    • Constructor Detail

      • CommitsApi

        public CommitsApi​(GitLabApi gitLabApi)
    • Method Detail

      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       int page,
                                       int perPage)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        page - the page to get
        perPage - the number of commits per page
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public Pager<Commit> getCommits​(Object projectIdOrPath,
                                        int itemsPerPage)
                                 throws GitLabApiException
        Get a Pager of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        itemsPerPage - the number of Commit instances that will be fetched per page
        Returns:
        a Pager containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitStream

        public Stream<Commit> getCommitStream​(Object projectIdOrPath)
                                       throws GitLabApiException
        Get a Stream of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        a Stream containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       String ref,
                                       Date since,
                                       Date until,
                                       String path)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        path - the path to file of a project
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       String ref,
                                       String path)
                                throws GitLabApiException
        Get a list of file commits in a project
        GitLab Endpoint: GET /projects/:id/repository/commits?path=:file_path
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        path - the path to file of a project
        Returns:
        a list containing the commits for the specified project ID and file
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       String ref,
                                       Date since,
                                       Date until)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       String ref,
                                       Date since,
                                       Date until,
                                       int page,
                                       int perPage)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        page - the page to get
        perPage - the number of commits per page
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitsStream

        public Stream<Commit> getCommitsStream​(Object projectIdOrPath,
                                               String ref,
                                               Date since,
                                               Date until)
                                        throws GitLabApiException
        Get a Stream of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        Returns:
        a Stream containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitsStream

        public Stream<Commit> getCommitsStream​(Object projectIdOrPath,
                                               String ref,
                                               Date since,
                                               Date until,
                                               String path)
                                        throws GitLabApiException
        Get a Stream of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        path - the path to file of a project
        Returns:
        a Stream containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public List<Commit> getCommits​(Object projectIdOrPath,
                                       String ref,
                                       Date since,
                                       Date until,
                                       String path,
                                       int page,
                                       int perPage)
                                throws GitLabApiException
        Get a list of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        path - the path to file of a project
        page - the page to get
        perPage - the number of commits per page
        Returns:
        a list containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public Pager<Commit> getCommits​(Object projectIdOrPath,
                                        String ref,
                                        Date since,
                                        Date until,
                                        int itemsPerPage)
                                 throws GitLabApiException
        Get a Pager of repository commits in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        itemsPerPage - the number of Commit instances that will be fetched per page
        Returns:
        a Pager containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommits

        public Pager<Commit> getCommits​(Object projectIdOrPath,
                                        String ref,
                                        Date since,
                                        Date until,
                                        String path,
                                        int itemsPerPage)
                                 throws GitLabApiException
        Get a Pager of repository commits in a project
        GitLab Endpoint: GET /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        ref - the name of a repository branch or tag or if not given the default branch
        since - only commits after or on this date will be returned
        until - only commits before or on this date will be returned
        itemsPerPage - the number of Commit instances that will be fetched per page
        path - the path to file of a project
        Returns:
        a Pager containing the commits for the specified project ID
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommit

        public Commit getCommit​(Object projectIdOrPath,
                                String sha)
                         throws GitLabApiException
        Get a specific commit identified by the commit hash or name of a branch or tag.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        the Commit instance for the specified project ID/sha pair
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getOptionalCommit

        public Optional<Commit> getOptionalCommit​(Object projectIdOrPath,
                                                  String sha)
        Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        the Commit for the specified project ID/sha pair as an Optional instance
      • getCommitRefs

        public List<CommitRef> getCommitRefs​(Object projectIdOrPath,
                                             String sha)
                                      throws GitLabApiException
        Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        Get all references (from branches or tags) a commit is pushed to
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
        Since:
        Gitlab 10.6
      • getCommitRefs

        public List<CommitRef> getCommitRefs​(Object projectIdOrPath,
                                             String sha,
                                             CommitRef.RefType refType)
                                      throws GitLabApiException
        Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        refType - the scope of commits. Possible values branch, tag, all. Default is all.
        Returns:
        Get all references (from branches or tags) a commit is pushed to
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
        Since:
        Gitlab 10.6
      • getCommitStatuses

        public List<CommitStatus> getCommitStatuses​(Object projectIdOrPath,
                                                    String sha,
                                                    CommitStatusFilter filter)
                                             throws GitLabApiException
        Get a list of repository commit statuses that meet the provided filter.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/statuses
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - the commit SHA
        filter - the commit statuses file, contains ref, stage, name, all
        Returns:
        a List containing the commit statuses for the specified project and sha that meet the provided filter
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitStatuses

        public List<CommitStatus> getCommitStatuses​(Object projectIdOrPath,
                                                    String sha,
                                                    CommitStatusFilter filter,
                                                    int page,
                                                    int perPage)
                                             throws GitLabApiException
        Get a list of repository commit statuses that meet the provided filter.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/statuses
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - the commit SHA
        filter - the commit statuses file, contains ref, stage, name, all
        page - the page to get
        perPage - the number of commits statuses per page
        Returns:
        a List containing the commit statuses for the specified project and sha that meet the provided filter
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitStatuses

        public Pager<CommitStatus> getCommitStatuses​(Object projectIdOrPath,
                                                     String sha,
                                                     CommitStatusFilter filter,
                                                     int itemsPerPage)
                                              throws GitLabApiException
        Get a Pager of repository commit statuses that meet the provided filter.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/statuses
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - the commit SHA
        filter - the commit statuses file, contains ref, stage, name, all
        itemsPerPage - the number of CommitStatus instances that will be fetched per page
        Returns:
        a Pager containing the commit statuses for the specified project and sha that meet the provided filter
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommitStatusesStream

        public Stream<CommitStatus> getCommitStatusesStream​(Object projectIdOrPath,
                                                            String sha,
                                                            CommitStatusFilter filter)
                                                     throws GitLabApiException
        Get a Stream of repository commit statuses that meet the provided filter.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/statuses
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - the commit SHA
        filter - the commit statuses file, contains ref, stage, name, all
        Returns:
        a Stream containing the commit statuses for the specified project and sha that meet the provided filter
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • addCommitStatus

        public CommitStatus addCommitStatus​(Object projectIdOrPath,
                                            String sha,
                                            Constants.CommitBuildState state,
                                            CommitStatus status)
                                     throws GitLabApiException

        Add or update the build status of a commit. The following fluent methods are available on the CommitStatus instance for setting up the status:

        
         withCoverage(Float)
         withDescription(String)
         withName(String)
         withRef(String)
         withTargetUrl(String)
         
        GitLab Endpoint: POST /projects/:id/statuses/:sha
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance (required)
        sha - a commit SHA (required)
        state - the state of the status. Can be one of the following: PENDING, RUNNING, SUCCESS, FAILED, CANCELED (required)
        status - the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage
        Returns:
        a CommitStatus instance with the updated info
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getDiff

        public List<Diff> getDiff​(Object projectIdOrPath,
                                  String sha)
                           throws GitLabApiException
        Get the list of diffs of a commit in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/diff
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        a List of Diff instances for the specified project ID/sha pair
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getComments

        public List<Comment> getComments​(Object projectIdOrPath,
                                         String sha)
                                  throws GitLabApiException
        Get the comments of a commit in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/comments
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        a List of Comment instances for the specified project ID/sha pair
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getComments

        public Pager<Comment> getComments​(Object projectIdOrPath,
                                          String sha,
                                          int itemsPerPage)
                                   throws GitLabApiException
        Get a Pager of the comments of a commit in a project.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/comments
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        itemsPerPage - the number of Comment instances that will be fetched per page
        Returns:
        a List of Comment instances for the specified project ID/sha pair
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • getCommentsStream

        public Stream<Comment> getCommentsStream​(Object projectIdOrPath,
                                                 String sha)
                                          throws GitLabApiException
        Get the comments of a commit in a project as a Stream.
        GitLab Endpoint: GET /projects/:id/repository/commits/:sha/comments
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        Returns:
        a Stream of Comment instances for the specified project ID/sha pair
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • addComment

        public Comment addComment​(Object projectIdOrPath,
                                  String sha,
                                  String note,
                                  String path,
                                  Integer line,
                                  Constants.LineType lineType)
                           throws GitLabApiException
        Add a comment to a commit. In order to post a comment in a particular line of a particular file, you must specify the full commit SHA, the path, the line and lineType should be NEW.
        GitLab Endpoint: POST /projects/:id/repository/commits/:sha/comments
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        note - the text of the comment, required
        path - the file path relative to the repository, optional
        line - the line number where the comment should be placed, optional
        lineType - the line type, optional
        Returns:
        a Comment instance for the posted comment
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • addComment

        public Comment addComment​(Object projectIdOrPath,
                                  String sha,
                                  String note)
                           throws GitLabApiException
        Add a comment to a commit.
        GitLab Endpoint: POST /projects/:id/repository/commits/:sha/comments
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - a commit hash or name of a branch or tag
        note - the text of the comment, required
        Returns:
        a Comment instance for the posted comment
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
      • createCommit

        public Commit createCommit​(Object projectIdOrPath,
                                   String branch,
                                   String commitMessage,
                                   String startBranch,
                                   String authorEmail,
                                   String authorName,
                                   CommitAction action)
                            throws GitLabApiException
        Create a commit with single file and action.
        GitLab Endpoint: POST /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        branch - tame of the branch to commit into. To create a new branch, also provide startBranch
        commitMessage - the commit message
        startBranch - the name of the branch to start the new commit from
        authorEmail - the commit author's email address
        authorName - the commit author's name
        action - the CommitAction to commit
        Returns:
        the created Commit instance
        Throws:
        GitLabApiException - if any exception occurs during execution
      • createCommit

        public Commit createCommit​(Object projectIdOrPath,
                                   String branch,
                                   String commitMessage,
                                   String startBranch,
                                   String authorEmail,
                                   String authorName,
                                   List<CommitAction> actions)
                            throws GitLabApiException
        Create a commit with multiple files and actions.
        GitLab Endpoint: POST /projects/:id/repository/commits
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        branch - tame of the branch to commit into. To create a new branch, also provide startBranch
        commitMessage - the commit message
        startBranch - the name of the branch to start the new commit from
        authorEmail - the commit author's email address
        authorName - the commit author's name
        actions - the array of CommitAction to commit as a batch
        Returns:
        the created Commit instance
        Throws:
        GitLabApiException - if any exception occurs during execution
      • revertCommit

        public Commit revertCommit​(Object projectIdOrPath,
                                   String sha,
                                   String branch)
                            throws GitLabApiException
        Reverts a commit in a given branch.
        GitLab Endpoint: POST /projects/:id/repository/commits/:sha/revert
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        sha - the commit SHA to revert
        branch - the target branch to revert the commit on
        Returns:
        a Commit instance holding the reverted commit
        Throws:
        GitLabApiException - GitLabApiException if any exception occurs during execution
        Since:
        GitLab 11.5