Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
ed5db399
Commit
ed5db399
authored
Jul 25, 2023
by
Jeremie Bresson
Browse files
Merge remote-tracking branch 'origin/main' into 6.x
parents
cf500e37
7d1d6b1a
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/MergeRequestApi.java
View file @
ed5db399
...
@@ -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
<
MergeRequest
Diff
>
getMergeRequestDiff
s
(
Object
projectIdOrPath
,
Long
mergeRequestIid
)
throws
GitLabApiException
{
public
List
<
MergeRequest
Version
>
getDiffVersion
s
(
Object
projectIdOrPath
,
Long
mergeRequestIid
)
throws
GitLabApiException
{
return
(
get
MergeRequestDiff
s
(
projectIdOrPath
,
mergeRequestIid
,
getDefaultPerPage
()).
all
());
return
(
get
DiffVersion
s
(
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
<
MergeRequest
Diff
>
getMergeRequestDiff
s
(
Object
projectIdOrPath
,
Long
mergeRequestIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
MergeRequest
Version
>
getDiffVersion
s
(
Object
projectIdOrPath
,
Long
mergeRequestIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
MergeRequest
Diff
>(
this
,
MergeRequest
Diff
.
class
,
itemsPerPage
,
null
,
return
(
new
Pager
<
MergeRequest
Version
>(
this
,
MergeRequest
Version
.
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
<
MergeRequest
Diff
>
getMergeRequestDiff
sStream
(
Object
projectIdOrPath
,
Long
mergeRequestIid
)
throws
GitLabApiException
{
public
Stream
<
MergeRequest
Version
>
getDiffVersion
sStream
(
Object
projectIdOrPath
,
Long
mergeRequestIid
)
throws
GitLabApiException
{
return
(
get
MergeRequestDiff
s
(
projectIdOrPath
,
mergeRequestIid
,
getDefaultPerPage
()).
stream
());
return
(
get
DiffVersion
s
(
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 MergeRequest
Diff
instance for the specified MR diff version
* @return a MergeRequest
Version
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 MergeRequest
Diff
as an Optional instance instance
* @return the specified MergeRequest
Version
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
(
get
MergeRequestDiff
(
projectIdOrPath
,
mergeRequestIid
,
versionId
)));
return
(
Optional
.
ofNullable
(
get
DiffVersion
(
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.
*
*
...
...
src/main/java/org/gitlab4j/api/models/MergeRequestDiff.java
View file @
ed5db399
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
;
}
}
...
...
src/main/java/org/gitlab4j/api/models/MergeRequestVersion.java
0 → 100644
View file @
ed5db399
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
));
}
}
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
ed5db399
...
@@ -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"
);
...
...
src/test/resources/org/gitlab4j/api/merge-request-versions.json
0 → 100644
View file @
ed5db399
[{
"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"
}]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment