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

Add missing branch protection fields #1732

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
217 changes: 217 additions & 0 deletions src/main/java/org/kohsuke/github/GHBranchProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,30 @@
public class GHBranchProtection extends GitHubInteractiveObject {
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";

@JsonProperty
private AllowDeletions allowDeletions;

@JsonProperty
private AllowForcePushes allowForcePushes;

@JsonProperty
private AllowForkSyncing allowForkSyncing;

@JsonProperty
private BlockCreations blockCreations;

@JsonProperty
private EnforceAdmins enforceAdmins;

@JsonProperty
private LockBranch lockBranch;

@JsonProperty
private RequiredConversationResolution requiredConversationResolution;

@JsonProperty
private RequiredLinearHistory requiredLinearHistory;

@JsonProperty("required_pull_request_reviews")
private RequiredReviews requiredReviews;

Expand Down Expand Up @@ -59,6 +80,42 @@ public void disableSignedCommits() throws IOException {
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
}

/**
* Gets allow deletions.
*
* @return the enforce admins
*/
public AllowDeletions getAllowDeletions() {
return allowDeletions;
}

/**
* Gets allow force pushes.
*
* @return the enforce admins
*/
public AllowForcePushes getAllowForcePushes() {
return allowForcePushes;
}

/**
* Gets allow fork syncing.
*
* @return the enforce admins
*/
public AllowForkSyncing getAllowForkSyncing() {
return allowForkSyncing;
}

/**
* Gets block creations.
*
* @return the enforce admins
*/
public BlockCreations getBlockCreations() {
return blockCreations;
}

/**
* Gets enforce admins.
*
Expand All @@ -68,6 +125,33 @@ public EnforceAdmins getEnforceAdmins() {
return enforceAdmins;
}

/**
* Gets lock branch.
*
* @return the enforce admins
*/
public LockBranch getLockBranch() {
return lockBranch;
}

/**
* Gets required conversation resolution.
*
* @return the enforce admins
*/
public RequiredConversationResolution getRequiredConversationResolution() {
return requiredConversationResolution;
}

/**
* Gets required linear history.
*
* @return the enforce admins
*/
public RequiredLinearHistory getRequiredLinearHistory() {
return requiredLinearHistory;
}

/**
* Gets required reviews.
*
Expand Down Expand Up @@ -120,6 +204,74 @@ private Requester requester() {
return root().createRequest().withPreview(ZZZAX);
}

/**
* The type AllowDeletions.
*/
public static class AllowDeletions {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type AllowForcePushes.
*/
public static class AllowForcePushes {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type AllowForkSyncing.
*/
public static class AllowForkSyncing {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type BlockCreations.
*/
public static class BlockCreations {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type EnforceAdmins.
*/
Expand Down Expand Up @@ -149,17 +301,73 @@ public boolean isEnabled() {
}
}

/**
* The type LockBranch.
*/
public static class LockBranch {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type RequiredConversationResolution.
*/
public static class RequiredConversationResolution {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type RequiredLinearHistory.
*/
public static class RequiredLinearHistory {
@JsonProperty
private boolean enabled;

/**
* Is enabled boolean.
*
* @return the boolean
*/
public boolean isEnabled() {
return enabled;
}
}

/**
* The type RequiredReviews.
*/
public static class RequiredReviews {
@JsonProperty("dismissal_restrictions")
private Restrictions dismissalRestriction;

@JsonProperty
private boolean dismissStaleReviews;

@JsonProperty
private boolean requireCodeOwnerReviews;

@JsonProperty
private boolean requireLastPushApproval;

@JsonProperty("required_approving_review_count")
private int requiredReviewers;

Expand Down Expand Up @@ -202,6 +410,15 @@ public boolean isRequireCodeOwnerReviews() {
return requireCodeOwnerReviews;
}

/**
* Is require last push approval boolean.
*
* @return the boolean
*/
public boolean isRequireLastPushApproval() {
return requireLastPushApproval;
}

/**
* Gets required reviewers.
*
Expand Down
Loading