Commit ed5db399 authored by Jeremie Bresson's avatar Jeremie Bresson
Browse files

Merge remote-tracking branch 'origin/main' into 6.x

parents cf500e37 7d1d6b1a
...@@ -15,11 +15,13 @@ import org.gitlab4j.api.models.ApprovalRule; ...@@ -15,11 +15,13 @@ import org.gitlab4j.api.models.ApprovalRule;
import org.gitlab4j.api.models.ApprovalRuleParams; import org.gitlab4j.api.models.ApprovalRuleParams;
import org.gitlab4j.api.models.ApprovalState; import org.gitlab4j.api.models.ApprovalState;
import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.Diff;
import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.Issue;
import org.gitlab4j.api.models.MergeRequest; import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.MergeRequestDiff; import org.gitlab4j.api.models.MergeRequestDiff;
import org.gitlab4j.api.models.MergeRequestFilter; import org.gitlab4j.api.models.MergeRequestFilter;
import org.gitlab4j.api.models.MergeRequestParams; import org.gitlab4j.api.models.MergeRequestParams;
import org.gitlab4j.api.models.MergeRequestVersion;
import org.gitlab4j.api.models.Participant; import org.gitlab4j.api.models.Participant;
import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.Pipeline;
...@@ -401,8 +403,8 @@ public class MergeRequestApi extends AbstractApi { ...@@ -401,8 +403,8 @@ public class MergeRequestApi extends AbstractApi {
* @return a List of merge request diff versions for the specified merge request * @return a List of merge request diff versions for the specified merge request
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<MergeRequestDiff> getMergeRequestDiffs(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { public List<MergeRequestVersion> getDiffVersions(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException {
return (getMergeRequestDiffs(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all()); return (getDiffVersions(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all());
} }
/** /**
...@@ -416,9 +418,9 @@ public class MergeRequestApi extends AbstractApi { ...@@ -416,9 +418,9 @@ public class MergeRequestApi extends AbstractApi {
* @return a Pager of merge request diff versions for the specified merge request * @return a Pager of merge request diff versions for the specified merge request
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Pager<MergeRequestDiff> getMergeRequestDiffs(Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException { public Pager<MergeRequestVersion> getDiffVersions(Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException {
return (new Pager<MergeRequestDiff>(this, MergeRequestDiff.class, itemsPerPage, null, return (new Pager<MergeRequestVersion>(this, MergeRequestVersion.class, itemsPerPage, null,
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "versions")); "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "versions"));
} }
/** /**
...@@ -431,8 +433,8 @@ public class MergeRequestApi extends AbstractApi { ...@@ -431,8 +433,8 @@ public class MergeRequestApi extends AbstractApi {
* @return a Stream of merge request diff versions for the specified merge request * @return a Stream of merge request diff versions for the specified merge request
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Stream<MergeRequestDiff> getMergeRequestDiffsStream(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { public Stream<MergeRequestVersion> getDiffVersionsStream(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException {
return (getMergeRequestDiffs(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream()); return (getDiffVersions(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream());
} }
/** /**
...@@ -443,11 +445,10 @@ public class MergeRequestApi extends AbstractApi { ...@@ -443,11 +445,10 @@ public class MergeRequestApi extends AbstractApi {
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request * @param mergeRequestIid the internal ID of the merge request
* @param versionId the ID of the merge request diff version * @param versionId the ID of the merge request diff version
* @return a MergeRequestDiff instance for the specified MR diff version * @return a MergeRequestVersion instance for the specified MR diff version
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public MergeRequestDiff getMergeRequestDiff(Object projectIdOrPath, public MergeRequestDiff getDiffVersion(Object projectIdOrPath, Long mergeRequestIid, Long versionId) throws GitLabApiException {
Long mergeRequestIid, Long versionId) throws GitLabApiException {
Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath),
"merge_requests", mergeRequestIid, "versions", versionId); "merge_requests", mergeRequestIid, "versions", versionId);
return (response.readEntity(MergeRequestDiff.class)); return (response.readEntity(MergeRequestDiff.class));
...@@ -461,17 +462,60 @@ public class MergeRequestApi extends AbstractApi { ...@@ -461,17 +462,60 @@ public class MergeRequestApi extends AbstractApi {
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request * @param mergeRequestIid the internal ID of the merge request
* @param versionId the ID of the merge request diff version * @param versionId the ID of the merge request diff version
* @return the specified MergeRequestDiff as an Optional instance instance * @return the specified MergeRequestVersion as an Optional instance instance
*/ */
public Optional<MergeRequestDiff> getOptionalMergeRequestDiff( public Optional<MergeRequestDiff> getOptionalDiffVersion(Object projectIdOrPath, Long mergeRequestIid, Long versionId) {
Object projectIdOrPath, Long mergeRequestIid, Long versionId) {
try { try {
return (Optional.ofNullable(getMergeRequestDiff(projectIdOrPath, mergeRequestIid, versionId))); return (Optional.ofNullable(getDiffVersion(projectIdOrPath, mergeRequestIid, versionId)));
} catch (GitLabApiException glae) { } catch (GitLabApiException glae) {
return (GitLabApi.createOptionalFromException(glae)); return (GitLabApi.createOptionalFromException(glae));
} }
} }
/**
* Get a list of merge request diffs.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a List of merge request diffs for the specified merge request
* @throws GitLabApiException if any exception occurs
*/
public List<Diff> getDiffs(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException {
return (getDiffs(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all());
}
/**
* Get a Pager of merge request diffs.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @param itemsPerPage the number of Diff instances that will be fetched per page
* @return a Pager of merge request diffs for the specified merge request
* @throws GitLabApiException if any exception occurs
*/
public Pager<Diff> getDiffs(Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException {
return (new Pager<>(this, Diff.class, itemsPerPage, null,
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "diffs"));
}
/**
* Get a Stream of merge request diffs.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a Stream of merge request diffs for the specified merge request
* @throws GitLabApiException if any exception occurs
*/
public Stream<Diff> getDiffsStream(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException {
return (getDiffs(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream());
}
/** /**
* Creates a merge request. * Creates a merge request.
* *
......
package org.gitlab4j.api.models; package org.gitlab4j.api.models;
import java.util.Date;
import java.util.List; import java.util.List;
import org.gitlab4j.api.utils.JacksonJson; import org.gitlab4j.api.utils.JacksonJson;
public class MergeRequestDiff { public class MergeRequestDiff extends MergeRequestVersion {
private Long id;
private String headCommitSha;
private String baseCommitSha;
private String startCommitSha;
private Date createdAt;
private Long mergeRequestId;
private String state;
private String realSize;
private List<Commit> commits; private List<Commit> commits;
private List<Diff> diffs; private List<Diff> diffs;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getHeadCommitSha() {
return headCommitSha;
}
public void setHeadCommitSha(String headCommitSha) {
this.headCommitSha = headCommitSha;
}
public String getBaseCommitSha() {
return baseCommitSha;
}
public void setBaseCommitSha(String baseCommitSha) {
this.baseCommitSha = baseCommitSha;
}
public String getStartCommitSha() {
return startCommitSha;
}
public void setStartCommitSha(String startCommitSha) {
this.startCommitSha = startCommitSha;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Long getMergeRequestId() {
return mergeRequestId;
}
public void setMergeRequestId(Long mergeRequestId) {
this.mergeRequestId = mergeRequestId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getRealSize() {
return realSize;
}
public void setRealSize(String realSize) {
this.realSize = realSize;
}
public List<Commit> getCommits() { public List<Commit> getCommits() {
return commits; return commits;
} }
......
package org.gitlab4j.api.models;
import java.util.Date;
import org.gitlab4j.api.utils.JacksonJson;
public class MergeRequestVersion {
private Long id;
private String headCommitSha;
private String baseCommitSha;
private String startCommitSha;
private Date createdAt;
private Long mergeRequestId;
private String state;
private String realSize;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getHeadCommitSha() {
return headCommitSha;
}
public void setHeadCommitSha(String headCommitSha) {
this.headCommitSha = headCommitSha;
}
public String getBaseCommitSha() {
return baseCommitSha;
}
public void setBaseCommitSha(String baseCommitSha) {
this.baseCommitSha = baseCommitSha;
}
public String getStartCommitSha() {
return startCommitSha;
}
public void setStartCommitSha(String startCommitSha) {
this.startCommitSha = startCommitSha;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Long getMergeRequestId() {
return mergeRequestId;
}
public void setMergeRequestId(Long mergeRequestId) {
this.mergeRequestId = mergeRequestId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getRealSize() {
return realSize;
}
public void setRealSize(String realSize) {
this.realSize = realSize;
}
@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
...@@ -86,6 +86,7 @@ import org.gitlab4j.api.models.LinkedIssue; ...@@ -86,6 +86,7 @@ import org.gitlab4j.api.models.LinkedIssue;
import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.Member;
import org.gitlab4j.api.models.MergeRequest; import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.MergeRequestDiff; import org.gitlab4j.api.models.MergeRequestDiff;
import org.gitlab4j.api.models.MergeRequestVersion;
import org.gitlab4j.api.models.Milestone; import org.gitlab4j.api.models.Milestone;
import org.gitlab4j.api.models.Note; import org.gitlab4j.api.models.Note;
import org.gitlab4j.api.models.NotificationSettings; import org.gitlab4j.api.models.NotificationSettings;
...@@ -664,6 +665,12 @@ public class TestGitLabApiBeans { ...@@ -664,6 +665,12 @@ public class TestGitLabApiBeans {
assertTrue(compareJson(diffs, "merge-request-diffs.json")); assertTrue(compareJson(diffs, "merge-request-diffs.json"));
} }
@Test
public void testMergeRequestVersions() throws Exception {
List<MergeRequestVersion> versions = unmarshalResourceList(MergeRequestVersion.class, "merge-request-versions.json");
assertTrue(compareJson(versions, "merge-request-diffs.json"));
}
@Test @Test
public void testMilestone() throws Exception { public void testMilestone() throws Exception {
Milestone milestone = unmarshalResource(Milestone.class, "milestone.json"); Milestone milestone = unmarshalResource(Milestone.class, "milestone.json");
......
[{
"id": 110,
"head_commit_sha": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30",
"base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd",
"start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd",
"created_at": "2016-07-26T14:44:48.926Z",
"merge_request_id": 105,
"state": "collected",
"real_size": "1"
}, {
"id": 108,
"head_commit_sha": "3eed087b29835c48015768f839d76e5ea8f07a24",
"base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd",
"start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd",
"created_at": "2016-07-25T14:21:33.028Z",
"merge_request_id": 105,
"state": "collected",
"real_size": "1"
}]
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