diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java index 5d1b3b48a2..3792fdcca3 100644 --- a/src/main/java/org/kohsuke/github/GHLabel.java +++ b/src/main/java/org/kohsuke/github/GHLabel.java @@ -34,4 +34,12 @@ public String getColor() { public void delete() throws IOException { repo.root.retrieve().method("DELETE").to(url); } + + /** + * @param newColor + * 6-letter hex color code, like "f29513" + */ + public void setColor(String newColor) throws IOException { + repo.root.retrieve().method("PATCH").with("name", name).with("color", newColor).to(url); + } } diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index 7087920dd7..f3041044b8 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -753,6 +753,10 @@ public void testRepoLabel() throws IOException { assertEquals(t.getColor(), "123456"); assertEquals(t.getColor(), t2.getColor()); assertEquals(t.getUrl(), t2.getUrl()); + + t.setColor("000000"); + GHLabel t3 = r.getLabel("test"); + assertEquals(t3.getColor(), "000000"); t.delete(); } }