Skip to content

Commit 6a40576

Browse files
authored
Merge branch 'main' into heek-feature-gitlab4j-1049-not-filter
2 parents bebbb90 + 47e9e67 commit 6a40576

File tree

208 files changed

+1455
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1455
-486
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To utilize GitLab4J™ API in your Java project, simply add the following de
5858
```java
5959
dependencies {
6060
...
61-
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '5.4.0'
61+
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '5.5.0'
6262
}
6363
```
6464

@@ -69,7 +69,7 @@ dependencies {
6969
<dependency>
7070
<groupId>org.gitlab4j</groupId>
7171
<artifactId>gitlab4j-api</artifactId>
72-
<version>5.4.0</version>
72+
<version>5.5.0</version>
7373
</dependency>
7474
```
7575

@@ -80,7 +80,7 @@ dependencies {
8080
Just add this line at the top of your script:
8181

8282
```java
83-
//DEPS org.gitlab4j:gitlab4j-api:5.4.0
83+
//DEPS org.gitlab4j:gitlab4j-api:5.5.0
8484
```
8585

8686
**Ivy and SBT**<br/>

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.gitlab4j</groupId>
66
<artifactId>gitlab4j-api</artifactId>
77
<packaging>jar</packaging>
8-
<version>5.4.0</version>
8+
<version>5.5.0</version>
99
<name>GitLab4J-API - GitLab API Java Client</name>
1010
<description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description>
1111
<url>https://github.com/gitlab4j/gitlab4j-api</url>
@@ -77,7 +77,7 @@
7777
<url>[email protected]:gitlab4j/gitlab4j-api.git</url>
7878
<connection>scm:git:[email protected]:gitlab4j/gitlab4j-api.git</connection>
7979
<developerConnection>scm:git:[email protected]:gitlab4j/gitlab4j-api.git</developerConnection>
80-
<tag>gitlab4j-api-5.4.0</tag>
80+
<tag>gitlab4j-api-5.5.0</tag>
8181
</scm>
8282

8383
<build>

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

+68
Original file line numberDiff line numberDiff line change
@@ -1029,5 +1029,73 @@ public String toString() {
10291029
return (enumHelper.toString(this));
10301030
}
10311031
}
1032+
1033+
/**
1034+
* Constant to specify the project_creation_level for the group.
1035+
*/
1036+
public enum ProjectCreationLevel {
1037+
NOONE, DEVELOPER, MAINTAINER;
1038+
1039+
private static JacksonJsonEnumHelper<ProjectCreationLevel> enumHelper = new JacksonJsonEnumHelper<>(ProjectCreationLevel.class);
1040+
1041+
@JsonCreator
1042+
public static ProjectCreationLevel forValue(String value) {
1043+
return enumHelper.forValue(value);
1044+
}
1045+
1046+
@JsonValue
1047+
public String toValue() {
1048+
return (enumHelper.toString(this));
1049+
}
1050+
1051+
@Override
1052+
public String toString() {
1053+
return (enumHelper.toString(this));
1054+
}
1055+
}
1056+
1057+
/**
1058+
* Constant to specify the subgroup_creation_level for the group.
1059+
*/
1060+
public enum SubgroupCreationLevel {
1061+
OWNER, MAINTAINER;
1062+
1063+
private static JacksonJsonEnumHelper<SubgroupCreationLevel> enumHelper = new JacksonJsonEnumHelper<>(SubgroupCreationLevel.class);
1064+
1065+
@JsonCreator
1066+
public static SubgroupCreationLevel forValue(String value) {
1067+
return enumHelper.forValue(value);
1068+
}
1069+
1070+
@JsonValue
1071+
public String toValue() {
1072+
return (enumHelper.toString(this));
1073+
}
1074+
1075+
@Override
1076+
public String toString() {
1077+
return (enumHelper.toString(this));
1078+
}
1079+
}
1080+
1081+
public enum DefaultBranchProtectionLevel {
1082+
NOT_PROTECTED(0),
1083+
PARTIALLY_PROTECTED(1),
1084+
FULLY_PROTECTED(2),
1085+
PROTECTED_AGAINST_PUSHES(3),
1086+
FULL_PROTECTION_AFTER_INITIAL_PUSH(4);
1087+
1088+
@JsonValue
1089+
private final int value;
1090+
1091+
private DefaultBranchProtectionLevel(int value) {
1092+
this.value = value;
1093+
}
1094+
1095+
@Override
1096+
public String toString() {
1097+
return Integer.toString(value);
1098+
}
1099+
}
10321100
}
10331101

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* with a GitLab API endpoint.
2323
*/
2424
public class GitLabApiException extends Exception {
25-
2625
private static final long serialVersionUID = 1L;
26+
2727
private StatusType statusInfo;
2828
private int httpStatus;
2929
private String message;

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

+51-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName)
136136
* @throws GitLabApiException if any exception occurs
137137
*/
138138
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel) throws GitLabApiException {
139-
return (protectBranch(projectIdOrPath, branchName, pushAccessLevel, mergeAccessLevel, null, null));
139+
return (protectBranch(projectIdOrPath, branchName, pushAccessLevel, mergeAccessLevel, null, null, null));
140140
}
141141

142142
/**
@@ -152,16 +152,39 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
152152
* @param codeOwnerApprovalRequired prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)
153153
* @return the branch info for the protected branch
154154
* @throws GitLabApiException if any exception occurs
155+
* @see ProtectedBranchesApi#protectBranch(Object, String, AccessLevel, AccessLevel, AccessLevel, Boolean, Boolean)
155156
*/
156157
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
157158
AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel, AccessLevel unprotectAccessLevel,
158159
Boolean codeOwnerApprovalRequired) throws GitLabApiException {
159-
Form formData = new GitLabApiForm()
160+
return protectBranch(projectIdOrPath, branchName, pushAccessLevel, mergeAccessLevel, unprotectAccessLevel, codeOwnerApprovalRequired, null);
161+
}
162+
163+
/**
164+
* Protects a single repository branch or several project repository branches using a wildcard protected branch.
165+
*
166+
* <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
167+
*
168+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
169+
* @param branchName the name of the branch to protect, can be a wildcard
170+
* @param pushAccessLevel access levels allowed to push (defaults: 40, maintainer access level)
171+
* @param mergeAccessLevel access levels allowed to merge (defaults: 40, maintainer access level)
172+
* @param unprotectAccessLevel access levels allowed to unprotect (defaults: 40, maintainer access level)
173+
* @param codeOwnerApprovalRequired prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)
174+
* @param allowForcedPush when enabled, members who can push to this branch can also force push. (default: false)
175+
* @return the branch info for the protected branch
176+
* @throws GitLabApiException if any exception occurs
177+
*/
178+
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
179+
AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel, AccessLevel unprotectAccessLevel,
180+
Boolean codeOwnerApprovalRequired, Boolean allowForcedPush) throws GitLabApiException {
181+
GitLabApiForm formData = new GitLabApiForm()
160182
.withParam("name", branchName, true)
161183
.withParam("push_access_level", pushAccessLevel)
162184
.withParam("merge_access_level", mergeAccessLevel)
163185
.withParam("unprotect_access_level", unprotectAccessLevel)
164-
.withParam("code_owner_approval_required", codeOwnerApprovalRequired);
186+
.withParam("code_owner_approval_required", codeOwnerApprovalRequired)
187+
.withParam("allow_force_push", allowForcedPush);
165188
Response response = post(Response.Status.CREATED, formData.asMap(),
166189
"projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
167190
return (response.readEntity(ProtectedBranch.class));
@@ -186,13 +209,37 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
186209
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
187210
Integer allowedToPushUserId, Integer allowedToMergeUserId, Integer allowedToUnprotectUserId,
188211
Boolean codeOwnerApprovalRequired) throws GitLabApiException {
212+
return protectBranch(projectIdOrPath, branchName, allowedToPushUserId, allowedToMergeUserId, allowedToUnprotectUserId, codeOwnerApprovalRequired, null);
213+
}
214+
215+
/**
216+
* Protects a single repository branch or several project repository branches using a wildcard protected branch.
217+
*
218+
* <p>NOTE: This method is only available to GitLab Starter, Bronze, or higher.</p>
219+
*
220+
* <pre><code>GitLab Endpoint: POST /projects/:id/protected_branches</code></pre>
221+
*
222+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
223+
* @param branchName the name of the branch to protect, can be a wildcard
224+
* @param allowedToPushUserId user ID allowed to push, can be null
225+
* @param allowedToMergeUserId user ID allowed to merge, can be null
226+
* @param allowedToUnprotectUserId user ID allowed to unprotect, can be null
227+
* @param codeOwnerApprovalRequired prevent pushes to this branch if it matches an item in the CODEOWNERS file. (defaults: false)
228+
* @param allowForcedPush when enabled, members who can push to this branch can also force push. (default: false)
229+
* @return the branch info for the protected branch
230+
* @throws GitLabApiException if any exception occurs
231+
*/
232+
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
233+
Integer allowedToPushUserId, Integer allowedToMergeUserId, Integer allowedToUnprotectUserId,
234+
Boolean codeOwnerApprovalRequired, Boolean allowForcedPush) throws GitLabApiException {
189235

190236
Form formData = new GitLabApiForm()
191237
.withParam("name", branchName, true)
192238
.withParam("allowed_to_push[][user_id]", allowedToPushUserId)
193239
.withParam("allowed_to_merge[][user_id]", allowedToMergeUserId)
194240
.withParam("allowed_to_unprotect[][user_id]", allowedToUnprotectUserId)
195-
.withParam("code_owner_approval_required", codeOwnerApprovalRequired);
241+
.withParam("code_owner_approval_required", codeOwnerApprovalRequired)
242+
.withParam("allow_force_push", allowForcedPush);
196243
Response response = post(Response.Status.CREATED, formData.asMap(),
197244
"projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
198245
return (response.readEntity(ProtectedBranch.class));

0 commit comments

Comments
 (0)