Skip to content

Commit fabfb5c

Browse files
committed
Merge branch '6.x' into update-mockito
Apply replacement: * "Mockito.<Object>any()" => "Mockito.any(Object[].class)"
2 parents 582bd66 + 98c4b99 commit fabfb5c

27 files changed

+933
-380
lines changed

src/main/java/org/gitlab4j/api/IssuesApi.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.gitlab4j.api.models.IssueLink;
1717
import org.gitlab4j.api.models.IssuesStatistics;
1818
import org.gitlab4j.api.models.IssuesStatisticsFilter;
19+
import org.gitlab4j.api.models.LinkType;
1920
import org.gitlab4j.api.models.MergeRequest;
2021
import org.gitlab4j.api.models.Participant;
2122
import org.gitlab4j.api.models.TimeStats;
@@ -889,10 +890,31 @@ public Stream<Issue> getIssueLinksStream(Object projectIdOrPath, Long issueIid)
889890
*/
890891
public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid,
891892
Object targetProjectIdOrPath, Long targetIssueIid) throws GitLabApiException {
893+
return createIssueLink(projectIdOrPath, issueIid, targetProjectIdOrPath, targetIssueIid, null);
894+
}
895+
896+
/**
897+
* Creates a two-way relation between two issues. User must be allowed to update both issues in order to succeed.
898+
*
899+
* <p>NOTE: Only available in GitLab Starter, GitLab Bronze, and higher tiers.</p>
900+
*
901+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/links</code></pre>
902+
*
903+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
904+
* @param issueIid the internal ID of a project's issue
905+
* @param targetProjectIdOrPath the project in the form of an Long(ID), String(path), or Project instance of the target project
906+
* @param targetIssueIid the internal ID of a target project’s issue
907+
* @param linkType the type of the relation (optional), defaults to {@link LinkType#RELATES_TO}.
908+
* @return an instance of IssueLink holding the link relationship
909+
* @throws GitLabApiException if any exception occurs
910+
*/
911+
public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid,
912+
Object targetProjectIdOrPath, Long targetIssueIid, LinkType linkType) throws GitLabApiException {
892913

893914
GitLabApiForm formData = new GitLabApiForm()
894915
.withParam("target_project_id", getProjectIdOrPath(targetProjectIdOrPath), true)
895-
.withParam("target_issue_iid", targetIssueIid, true);
916+
.withParam("target_issue_iid", targetIssueIid, true)
917+
.withParam("link_type", linkType, false);
896918

897919
Response response = post(Response.Status.OK, formData.asMap(),
898920
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links");

src/main/java/org/gitlab4j/api/Pager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
6969
* @param pathArgs HTTP path arguments
7070
* @throws GitLabApiException if any error occurs
7171
*/
72-
Pager(AbstractApi api, Class<T> type, int itemsPerPage, MultivaluedMap<String, String> queryParams, Object... pathArgs) throws GitLabApiException {
72+
public Pager(AbstractApi api, Class<T> type, int itemsPerPage, MultivaluedMap<String, String> queryParams, Object... pathArgs) throws GitLabApiException {
7373

7474
javaType = mapper.getTypeFactory().constructCollectionType(List.class, type);
7575

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.gitlab4j.api;
2+
3+
import jakarta.ws.rs.core.Response;
4+
5+
import org.gitlab4j.api.models.Commit;
6+
7+
/**
8+
* <p>This class provides an entry point to all the GitLab API repository submodules calls.
9+
* For more information on the repository APIs see:</p>
10+
*
11+
* @see <a href="https://docs.gitlab.com/ee/api/repository_submodules.html">Repository Submodules API</a>
12+
*/
13+
public class RepositorySubmodulesApi extends AbstractApi {
14+
15+
public RepositorySubmodulesApi(GitLabApi gitLabApi) {
16+
super(gitLabApi);
17+
}
18+
19+
/**
20+
* Update existing submodule reference in repository.
21+
*
22+
* <pre><code>GitLab Endpoint: PUT /projects/:id/repository/submodules/:submodule</code></pre>
23+
*
24+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
25+
* @param submodule full path to the submodule
26+
* @param branch name of the branch to commit into
27+
* @param commitSha full commit SHA to update the submodule to
28+
* @param commitMessage commit message (optional). If no message is provided, a default is set
29+
* @return the created commit
30+
* @throws GitLabApiException if any exception occurs
31+
*/
32+
public Commit updateExistingSubmoduleReference(Object projectIdOrPath, String submodule, String branch, String commitSha, String commitMessage) throws GitLabApiException {
33+
GitLabApiForm formData = new GitLabApiForm()
34+
.withParam("branch", branch, true)
35+
.withParam("commit_sha", commitSha, true)
36+
.withParam("commit_message", commitMessage);
37+
Response response = put(Response.Status.OK, formData.asMap(), "projects",
38+
getProjectIdOrPath(projectIdOrPath), "repository", "submodules", urlEncode(submodule));
39+
return (response.readEntity(Commit.class));
40+
}
41+
42+
}

0 commit comments

Comments
 (0)