Unverified Commit bcd63b71 authored by An Phi's avatar An Phi Committed by GitHub
Browse files

Add a method to get Pager of commit refs (#506)

parent 0a41a569
...@@ -362,7 +362,7 @@ public class CommitsApi extends AbstractApi { ...@@ -362,7 +362,7 @@ public class CommitsApi extends AbstractApi {
} }
/** /**
* Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance * Get all references (from branches or tags) a commit is pushed to
* *
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs</code></pre> * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs</code></pre>
* *
...@@ -377,7 +377,23 @@ public class CommitsApi extends AbstractApi { ...@@ -377,7 +377,23 @@ public class CommitsApi extends AbstractApi {
} }
/** /**
* Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance * Get all references (from branches or tags) a commit is pushed to
*
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha a commit hash or name of a branch or tag
* @param itemsPerPage the number of Commit instances that will be fetched per page
* @return 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
*/
public Pager<CommitRef> getCommitRefs(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException {
return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, itemsPerPage));
}
/**
* Get all references (from branches or tags) a commit is pushed to
* *
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType</code></pre> * <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType</code></pre>
* *
...@@ -396,6 +412,24 @@ public class CommitsApi extends AbstractApi { ...@@ -396,6 +412,24 @@ public class CommitsApi extends AbstractApi {
return (response.readEntity(new GenericType<List<CommitRef>>(){})); return (response.readEntity(new GenericType<List<CommitRef>>(){}));
} }
/**
* Get all references (from branches or tags) a commit is pushed to
*
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param sha a commit hash or name of a branch or tag
* @param refType the scope of commits. Possible values branch, tag, all. Default is all.
* @param itemsPerPage the number of Commit instances that will be fetched per page
* @return 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
*/
public Pager<CommitRef> getCommitRefs(Object projectIdOrPath, String sha, CommitRef.RefType refType, int itemsPerPage) throws GitLabApiException {
Form form = new GitLabApiForm().withParam("type", refType);
return (new Pager<CommitRef>(this, CommitRef.class, itemsPerPage, form.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha), "refs"));
}
/** /**
* Get a list of repository commit statuses that meet the provided filter. * Get a list of repository commit statuses that meet the provided filter.
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment