From 569fa06d2dd51877b3df7b7807c60ae18e167198 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Wed, 25 Oct 2017 14:06:28 +0200 Subject: [PATCH 1/2] Labels: add method to update color --- src/main/java/org/kohsuke/github/GHLabel.java | 4 ++++ src/test/java/org/kohsuke/github/AppTest.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java index 5d1b3b48a2..83a6964a97 100644 --- a/src/main/java/org/kohsuke/github/GHLabel.java +++ b/src/main/java/org/kohsuke/github/GHLabel.java @@ -34,4 +34,8 @@ public String getColor() { public void delete() throws IOException { repo.root.retrieve().method("DELETE").to(url); } + + public void updateColor(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..6c7a84bbc3 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.updateColor("000000"); + GHLabel t3 = r.getLabel("test"); + assertEquals(t3.getColor(), "000000"); t.delete(); } } From e94ba74058fa806af30095b1a4c38c0196c6569c Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 28 Oct 2017 07:44:23 -0700 Subject: [PATCH 2/2] Convention is to call these methods setXyz. Plus doc --- src/main/java/org/kohsuke/github/GHLabel.java | 6 +++++- src/test/java/org/kohsuke/github/AppTest.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java index 83a6964a97..3792fdcca3 100644 --- a/src/main/java/org/kohsuke/github/GHLabel.java +++ b/src/main/java/org/kohsuke/github/GHLabel.java @@ -35,7 +35,11 @@ public void delete() throws IOException { repo.root.retrieve().method("DELETE").to(url); } - public void updateColor(String newColor) throws IOException { + /** + * @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 6c7a84bbc3..f3041044b8 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -754,7 +754,7 @@ public void testRepoLabel() throws IOException { assertEquals(t.getColor(), t2.getColor()); assertEquals(t.getUrl(), t2.getUrl()); - t.updateColor("000000"); + t.setColor("000000"); GHLabel t3 = r.getLabel("test"); assertEquals(t3.getColor(), "000000"); t.delete();