Package org.gitlab4j.api
Class CommitsApi
- java.lang.Object
-
- org.gitlab4j.api.AbstractApi
-
- org.gitlab4j.api.CommitsApi
-
- All Implemented Interfaces:
Constants
public class CommitsApi extends AbstractApi
This class implements the client side API for the GitLab commits calls. See Commits API at GitLab for more information.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.Encoding, Constants.EpicOrderBy, Constants.GroupOrderBy, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenType
-
-
Field Summary
-
Fields inherited from interface org.gitlab4j.api.Constants
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
-
-
Constructor Summary
Constructors Constructor Description CommitsApi(GitLabApi gitLabApi)
-
Method Summary
Modifier and Type Method Description Comment
addComment(Object projectIdOrPath, String sha, String note)
Add a comment to a commit.Comment
addComment(Object projectIdOrPath, String sha, String note, String path, Integer line, Constants.LineType lineType)
Add a comment to a commit.CommitStatus
addCommitStatus(Object projectIdOrPath, String sha, Constants.CommitBuildState state, CommitStatus status)
Add or update the build status of a commit.Commit
createCommit(Object projectIdOrPath, String branch, String commitMessage, String startBranch, String authorEmail, String authorName, List<CommitAction> actions)
Create a commit with multiple files and actions.List<Comment>
getComments(Object projectIdOrPath, String sha)
Get the comments of a commit in a project.Pager<Comment>
getComments(Object projectIdOrPath, String sha, int itemsPerPage)
Get a Pager of the comments of a commit in a project.Stream<Comment>
getCommentsStream(Object projectIdOrPath, String sha)
Get the comments of a commit in a project as a Stream.Commit
getCommit(Object projectIdOrPath, String sha)
Get a specific commit identified by the commit hash or name of a branch or tag.List<CommitRef>
getCommitRefs(Object projectIdOrPath, String sha)
Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instanceList<CommitRef>
getCommitRefs(Object projectIdOrPath, String sha, CommitRef.RefType refType)
Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instanceList<Commit>
getCommits(Object projectIdOrPath)
Get a list of repository commits in a project.Pager<Commit>
getCommits(Object projectIdOrPath, int itemsPerPage)
Get a Pager of repository commits in a project.List<Commit>
getCommits(Object projectIdOrPath, int page, int perPage)
Get a list of repository commits in a project.List<Commit>
getCommits(Object projectIdOrPath, String ref, String path)
Get a list of file commits in a projectList<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until)
Get a list of repository commits in a project.Pager<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until, int itemsPerPage)
Get a Pager of repository commits in a project.List<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until, int page, int perPage)
Get a list of repository commits in a project.List<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path)
Get a list of repository commits in a project.Pager<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int itemsPerPage)
Get a Pager of repository commits in a projectList<Commit>
getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int page, int perPage)
Get a list of repository commits in a project.Stream<Commit>
getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until)
Get a Stream of repository commits in a project.Stream<Commit>
getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until, String path)
Get a Stream of repository commits in a project.List<CommitStatus>
getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter)
Get a list of repository commit statuses that meet the provided filter.Pager<CommitStatus>
getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter, int itemsPerPage)
Get a Pager of repository commit statuses that meet the provided filter.List<CommitStatus>
getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter, int page, int perPage)
Get a list of repository commit statuses that meet the provided filter.Stream<CommitStatus>
getCommitStatusesStream(Object projectIdOrPath, String sha, CommitStatusFilter filter)
Get a Stream of repository commit statuses that meet the provided filter.Stream<Commit>
getCommitStream(Object projectIdOrPath)
Get a Stream of repository commits in a project.List<Diff>
getDiff(Object projectIdOrPath, String sha)
Get the list of diffs of a commit in a project.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-
Methods inherited from class org.gitlab4j.api.AbstractApi
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, urlEncode, validate
-
-
-
-
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 instancepage
- the page to getperPage
- 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 instanceitemsPerPage
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returnedpath
- 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 projectGitLab Endpoint: GET /projects/:id/repository/commits?path=:file_path
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instanceref
- the name of a repository branch or tag or if not given the default branchpath
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returnedpage
- the page to getperPage
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returnedpath
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returnedpath
- the path to file of a projectpage
- the page to getperPage
- 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 instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returneditemsPerPage
- 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 projectGitLab Endpoint: GET /projects/:id/repository/commits
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instanceref
- the name of a repository branch or tag or if not given the default branchsince
- only commits after or on this date will be returneduntil
- only commits before or on this date will be returneditemsPerPage
- the number of Commit instances that will be fetched per pagepath
- 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 instancesha
- 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 instanceGitLab Endpoint: GET /projects/:id/repository/commits/:sha
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancesha
- 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 instanceGitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
- Parameters:
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancesha
- 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 instanceGitLab 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 instancesha
- a commit hash or name of a branch or tagrefType
- 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 instancesha
- the commit SHAfilter
- 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 instancesha
- the commit SHAfilter
- the commit statuses file, contains ref, stage, name, allpage
- the page to getperPage
- 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 instancesha
- the commit SHAfilter
- the commit statuses file, contains ref, stage, name, allitemsPerPage
- 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 instancesha
- the commit SHAfilter
- 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 instancesha
- 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 instancesha
- 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 instancesha
- a commit hash or name of a branch or tagitemsPerPage
- 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 instancesha
- 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 instancesha
- a commit hash or name of a branch or tagnote
- the text of the comment, requiredpath
- the file path relative to the repository, optionalline
- the line number where the comment should be placed, optionallineType
- 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 instancesha
- a commit hash or name of a branch or tagnote
- 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, 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 instancebranch
- tame of the branch to commit into. To create a new branch, also provide startBranchcommitMessage
- the commit messagestartBranch
- the name of the branch to start the new commit fromauthorEmail
- the commit author's email addressauthorName
- the commit author's nameactions
- the array of CommitAction to commit as a batch- Returns:
- the create Commit instance
- Throws:
GitLabApiException
- if any exception occurs during execution
-
-