Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new api call for forced push checks #1071 #1072

Merged
merged 5 commits into from
Dec 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main/java/org/gitlab4j/api/ProtectedBranchesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName)
* @throws GitLabApiException if any exception occurs
*/
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName, AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel) throws GitLabApiException {
return (protectBranch(projectIdOrPath, branchName, pushAccessLevel, mergeAccessLevel, null, null));
return (protectBranch(projectIdOrPath, branchName, pushAccessLevel, mergeAccessLevel, null, null, null));
}

/**
Expand All @@ -155,13 +155,14 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
*/
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
AccessLevel pushAccessLevel, AccessLevel mergeAccessLevel, AccessLevel unprotectAccessLevel,
Boolean codeOwnerApprovalRequired) throws GitLabApiException {
Boolean codeOwnerApprovalRequired, Boolean allowForcedPush) throws GitLabApiException {
jmini marked this conversation as resolved.
Show resolved Hide resolved
Form formData = new GitLabApiForm()
.withParam("name", branchName, true)
.withParam("push_access_level", pushAccessLevel)
.withParam("merge_access_level", mergeAccessLevel)
.withParam("unprotect_access_level", unprotectAccessLevel)
.withParam("code_owner_approval_required", codeOwnerApprovalRequired);
.withParam("code_owner_approval_required", codeOwnerApprovalRequired)
.withParam("allow_force_push", allowForcedPush);
Response response = post(Response.Status.CREATED, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
return (response.readEntity(ProtectedBranch.class));
Expand All @@ -185,14 +186,15 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
*/
public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
Integer allowedToPushUserId, Integer allowedToMergeUserId, Integer allowedToUnprotectUserId,
Boolean codeOwnerApprovalRequired) throws GitLabApiException {
Boolean codeOwnerApprovalRequired, Boolean allowForcedPush) throws GitLabApiException {
jmini marked this conversation as resolved.
Show resolved Hide resolved

Form formData = new GitLabApiForm()
.withParam("name", branchName, true)
.withParam("allowed_to_push[][user_id]", allowedToPushUserId)
.withParam("allowed_to_merge[][user_id]", allowedToMergeUserId)
.withParam("allowed_to_unprotect[][user_id]", allowedToUnprotectUserId)
.withParam("code_owner_approval_required", codeOwnerApprovalRequired);
.withParam("code_owner_approval_required", codeOwnerApprovalRequired)
.withParam("allow_force_push", allowForcedPush);
Response response = post(Response.Status.CREATED, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
return (response.readEntity(ProtectedBranch.class));
Expand Down Expand Up @@ -228,6 +230,7 @@ public ProtectedBranch protectBranch(Object projectIdOrPath, String branchName,
allowedToMerge.getForm(formData, "allowed_to_merge");
if (allowedToUnprotect != null)
allowedToUnprotect.getForm(formData, "allowed_to_unprotect");
//FIXME: cannot test, having CE only to test
jmini marked this conversation as resolved.
Show resolved Hide resolved

Response response = post(Response.Status.CREATED, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "protected_branches");
Expand Down
Loading