From 26c20a7a224a066bb06b71461143ec517669dd61 Mon Sep 17 00:00:00 2001 From: "Jeffrey.Nelson" Date: Thu, 22 Dec 2016 11:55:01 -0600 Subject: [PATCH 1/2] add branch protection attributes --- .../java/org/kohsuke/github/GHBranch.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index 4c80db9ef4..9870732d0d 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -1,13 +1,16 @@ package org.kohsuke.github; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.kohsuke.github.BranchProtection.RequiredStatusChecks; +import static org.kohsuke.github.Previews.LOKI; import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import static org.kohsuke.github.Previews.LOKI; +import org.kohsuke.github.BranchProtection.RequiredStatusChecks; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** * A branch in a repository. @@ -22,6 +25,10 @@ public class GHBranch { private String name; private Commit commit; + @JsonProperty("protected") + private boolean protection; + private String protection_url; + public static class Commit { String sha; @@ -44,6 +51,15 @@ public GHRepository getOwner() { public String getName() { return name; } + + public boolean isProtected() { + return protection; + } + + public String getProtection_url() { + return protection_url; + } + /** * The commit that this branch currently points to. From 1212ae3eb3f854ea903675ffe6535af6982d5808 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 9 Jan 2017 16:06:05 -0800 Subject: [PATCH 2/2] Touch up for uniformity - Prefer typed 'URL' over 'String' that is URL - Mark API as @Preview to communicate that this is subject to change More branch protection stuff needs to be added. See https://developer.github.com/v3/repos/branches/ --- src/main/java/org/kohsuke/github/GHBranch.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHBranch.java b/src/main/java/org/kohsuke/github/GHBranch.java index 9870732d0d..f54bea9f47 100644 --- a/src/main/java/org/kohsuke/github/GHBranch.java +++ b/src/main/java/org/kohsuke/github/GHBranch.java @@ -3,6 +3,7 @@ import static org.kohsuke.github.Previews.LOKI; import java.io.IOException; +import java.net.URL; import java.util.Arrays; import java.util.Collection; @@ -51,13 +52,21 @@ public GHRepository getOwner() { public String getName() { return name; } - + + /** + * Returns true if the push to this branch is restricted via branch protection. + */ + @Preview @Deprecated public boolean isProtected() { - return protection; + return protection; } - public String getProtection_url() { - return protection_url; + /** + * Returns API URL that deals with the protection of this branch. + */ + @Preview @Deprecated + public URL getProtectionUrl() { + return GitHub.parseURL(protection_url); }