Skip to content

Commit 8267a27

Browse files
Merge branch 'gitlab4j:main' into bugfix/MergeRequestEvent_object_attributes
2 parents 1281363 + 952ce31 commit 8267a27

File tree

9 files changed

+787
-709
lines changed

9 files changed

+787
-709
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ build/
5252
!/gradle/wrapper/gradle-wrapper.jar
5353

5454
# Test properties file for gitlab4j
55-
test-gitlab4j.properties
56-
!src/test/resources/test-gitlab4j.properties
55+
gitlab4j-mock-config-*.properties
5756

5857
# git-changelog plugin #
5958
.okhttpcache

README.md

Lines changed: 700 additions & 701 deletions
Large diffs are not rendered by default.

gitlab4j-api/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ dependencies {
1111
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
1212
testImplementation 'org.hamcrest:hamcrest-all:1.3'
1313
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.0.2'
14-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
15-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
14+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.13.4"
15+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.13.4"
16+
testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.13.4"
1617
}
1718

1819
publishing {

gitlab4j-api/src/main/java/org/gitlab4j/api/AwardEmojiApi.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,28 @@ public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long
436436
* @param name the name of the award emoji to add
437437
* @return an AwardEmoji instance for the added award emoji
438438
* @throws GitLabApiException if any exception occurs
439+
* @deprecated use {@link #addMergeRequestAwardEmoji(Object, Long, Long, String)} instead
439440
*/
441+
@Deprecated
440442
public AwardEmoji addMergeRequestAwardEmoji(
441443
Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, String name) throws GitLabApiException {
444+
return addMergeRequestAwardEmoji(projectIdOrPath, mergeRequestIid.longValue(), noteId.longValue(), name);
445+
}
446+
447+
/**
448+
* Add an award emoji for the specified merge request note.
449+
*
450+
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji</code></pre>
451+
*
452+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
453+
* @param mergeRequestIid the merge request IID of the merge request that owns the note
454+
* @param noteId the note ID to add the award emoji to
455+
* @param name the name of the award emoji to add
456+
* @return an AwardEmoji instance for the added award emoji
457+
* @throws GitLabApiException if any exception occurs
458+
*/
459+
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long noteId, String name)
460+
throws GitLabApiException {
442461
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
443462
Response response = post(
444463
Response.Status.CREATED,

gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ public Project createProject(Project project) throws GitLabApiException {
10741074
* ciConfigPath (optional) - Set path to CI configuration file
10751075
* autoDevopsEnabled (optional) - Enable Auto DevOps for this project
10761076
* squashOption (optional) - set squash option for merge requests
1077+
* ciDeletePipelinesInSeconds (optional) - set the automatic pipeline cleanup time in seconds
10771078
*
10781079
* @param project the Project instance with the configuration for the new project
10791080
* @param importUrl the URL to import the repository from
@@ -1125,6 +1126,7 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
11251126
.withParam("build_git_strategy", project.getBuildGitStrategy())
11261127
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
11271128
.withParam("ci_config_path", project.getCiConfigPath())
1129+
.withParam("ci_delete_pipelines_in_seconds", project.getCiDeletePipelinesInSeconds())
11281130
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
11291131
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
11301132
.withParam("auto_devops_enabled", project.getAutoDevopsEnabled())
@@ -1445,6 +1447,7 @@ public Project createProjectFromTemplate(
14451447
* ciConfigPath (optional) - Set path to CI configuration file
14461448
* ciForwardDeploymentEnabled (optional) - When a new deployment job starts, skip older deployment jobs that are still pending
14471449
* squashOption (optional) - set squash option for merge requests
1450+
* ciDeletePipelinesInSeconds (optional) - set the automatic pipeline cleanup time in seconds
14481451
*
14491452
* NOTE: The following parameters specified by the GitLab API edit project are not supported:
14501453
* import_url
@@ -1494,6 +1497,7 @@ public Project updateProject(Project project) throws GitLabApiException {
14941497
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
14951498
.withParam("ci_config_path", project.getCiConfigPath())
14961499
.withParam("ci_forward_deployment_enabled", project.getCiForwardDeploymentEnabled())
1500+
.withParam("ci_delete_pipelines_in_seconds", project.getCiDeletePipelinesInSeconds())
14971501
.withParam("merge_method", project.getMergeMethod())
14981502
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
14991503
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
@@ -3972,6 +3976,44 @@ public List<Badge> getBadges(Object projectIdOrPath, String bagdeName) throws Gi
39723976
return (response.readEntity(new GenericType<List<Badge>>() {}));
39733977
}
39743978

3979+
/**
3980+
* Gets a pager of a project’s badges and its group badges.
3981+
*
3982+
* <pre><code>GitLab Endpoint: GET /projects/:id/badges</code></pre>
3983+
*
3984+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
3985+
* @param itemsPerPage the number of Badge instances that will be fetched per page
3986+
* @return a pager of Badge instances for the specified project
3987+
* @throws GitLabApiException if any exception occurs
3988+
*/
3989+
public Pager<Badge> getBadges(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
3990+
return getBadges(projectIdOrPath, null, itemsPerPage);
3991+
}
3992+
3993+
/**
3994+
* Gets a pager of a project’s badges and its group badges, case-sensitively filtered on bagdeName if non-null.
3995+
*
3996+
* <pre><code>GitLab Endpoint: GET /projects/:id/badges?name=:name</code></pre>
3997+
*
3998+
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
3999+
* @param bagdeName The name to filter on (case-sensitive), ignored if null.
4000+
* @param itemsPerPage the number of Badge instances that will be fetched per page
4001+
* @return a pager of the GitLab item, case insensitively filtered on name.
4002+
* @throws GitLabApiException If any problem is encountered
4003+
*/
4004+
public Pager<Badge> getBadges(Object projectIdOrPath, String bagdeName, int itemsPerPage)
4005+
throws GitLabApiException {
4006+
Form queryParam = new GitLabApiForm().withParam("name", bagdeName);
4007+
return new Pager<Badge>(
4008+
this,
4009+
Badge.class,
4010+
itemsPerPage,
4011+
queryParam.asMap(),
4012+
"projects",
4013+
getProjectIdOrPath(projectIdOrPath),
4014+
"badges");
4015+
}
4016+
39754017
/**
39764018
* Gets a badge of a project.
39774019
*

gitlab4j-api/src/test/java/org/gitlab4j/api/TestProjectApi.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ public void testUpdate() throws GitLabApiException {
274274
.withTagList(Arrays.asList("tag1", "tag2"))
275275
.withMergeMethod(Project.MergeMethod.MERGE)
276276
.withSuggestionCommitMessage("SuggestionCommitMessageOriginal")
277-
.withRemoveSourceBranchAfterMerge(false);
277+
.withRemoveSourceBranchAfterMerge(false)
278+
.withCiDeletePipelineInSeconds(3600);
278279

279280
Project newProject = gitLabApi.getProjectApi().createProject(project);
280281
assertNotNull(newProject);
@@ -289,6 +290,7 @@ public void testUpdate() throws GitLabApiException {
289290
assertEquals(Project.MergeMethod.MERGE, newProject.getMergeMethod());
290291
assertEquals(project.getSuggestionCommitMessage(), newProject.getSuggestionCommitMessage());
291292
assertEquals(project.getRemoveSourceBranchAfterMerge(), newProject.getRemoveSourceBranchAfterMerge());
293+
assertEquals(project.getCiDeletePipelinesInSeconds(), newProject.getCiDeletePipelinesInSeconds());
292294

293295
project = new Project()
294296
.withId(newProject.getId())

gitlab4j-models/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ dependencies {
55
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
66
testImplementation 'org.hamcrest:hamcrest-all:1.3'
77
testImplementation 'uk.org.webcompere:system-stubs-jupiter:2.0.2'
8-
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.4"
9-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
8+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.13.4"
9+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.13.4"
10+
testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.13.4"
1011
}
1112

1213
publishing {

gitlab4j-models/src/main/java/org/gitlab4j/api/models/Project.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public String toString() {
302302
private String ciRestrictPipelineCancellationRole;
303303
private String ciPipelineVariablesMinimumOverrideRole;
304304
private Boolean ciPushRepositoryForJobTokenAllowed;
305+
private Integer ciDeletePipelinesInSeconds;
305306
private Boolean allowPipelineTriggerApproveDeployment;
306307
private Boolean restrictUserDefinedVariables;
307308
private Boolean enforceAuthChecksOnUploads;
@@ -1531,6 +1532,19 @@ public void setCiPushRepositoryForJobTokenAllowed(Boolean ciPushRepositoryForJob
15311532
this.ciPushRepositoryForJobTokenAllowed = ciPushRepositoryForJobTokenAllowed;
15321533
}
15331534

1535+
public Integer getCiDeletePipelinesInSeconds() {
1536+
return ciDeletePipelinesInSeconds;
1537+
}
1538+
1539+
public void setCiDeletePipelinesInSeconds(Integer ciDeletePipelinesInSeconds) {
1540+
this.ciDeletePipelinesInSeconds = ciDeletePipelinesInSeconds;
1541+
}
1542+
1543+
public Project withCiDeletePipelineInSeconds(Integer ciDeletePipelineInSeconds) {
1544+
this.ciDeletePipelinesInSeconds = ciDeletePipelineInSeconds;
1545+
return this;
1546+
}
1547+
15341548
public Boolean getAllowPipelineTriggerApproveDeployment() {
15351549
return allowPipelineTriggerApproveDeployment;
15361550
}

gitlab4j-models/src/test/resources/org/gitlab4j/models/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,6 @@
194194
"requirements_access_level" : "enabled",
195195
"security_and_compliance_access_level" : "private",
196196
"snippets_access_level" : "enabled",
197-
"wiki_access_level" : "enabled"
197+
"wiki_access_level" : "enabled",
198+
"ci_delete_pipelines_in_seconds": 604800
198199
}

0 commit comments

Comments
 (0)