-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a task that will remove github labels from an issue.
Refs #7.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/ListGithubIssuesTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.glasstowerstudios.gruel.tasks.github | ||
|
||
import com.glasstowerstudios.gruel.tasks.github.GithubTask | ||
import org.gradle.api.tasks.TaskAction | ||
import org.kohsuke.github.GitHub | ||
import org.kohsuke.github.GHRepository | ||
import org.kohsuke.github.GHIssueState | ||
|
||
class ListGithubIssuesTask extends GithubTask { | ||
@TaskAction | ||
def doTask() { | ||
def repo = getRepository() | ||
def issues = repo.getIssues(GHIssueState.ALL); | ||
for (def nextIssue : issues) { | ||
println "Issue #" + nextIssue.number + ": " + nextIssue.title | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...in/groovy/com/glasstowerstudios/gruel/tasks/github/RemoveLabelsFromGithubIssueTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.glasstowerstudios.gruel.tasks.github | ||
|
||
import com.glasstowerstudios.gruel.tasks.github.GithubTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* A type of {@link GithubTask} that will remove a set of labels from the github | ||
* issue having a specified issue number. | ||
*/ | ||
class RemoveLabelsFromGithubIssueTask extends GithubTask { | ||
public static final String ALL = "all" | ||
|
||
private int issueNumber; | ||
private List<String> labels; | ||
|
||
void setIssueNumber(int issueNumber) { | ||
this.issueNumber = issueNumber; | ||
} | ||
|
||
void setLabels(List<String> labels) { | ||
this.labels = labels; | ||
} | ||
|
||
List<String> getLabels() { | ||
return this.labels; | ||
} | ||
|
||
int getIssueNumber() { | ||
return this.issueNumber; | ||
} | ||
|
||
@TaskAction | ||
def doTask() { | ||
def repo = project.github.connectToRepository() | ||
def issue = repo.getIssue(this.issueNumber) | ||
def issueLabels = issue.getLabels() | ||
def labelsToKeep = [] | ||
for (def nextLabel : issueLabels) { | ||
if (!this.labels.contains(nextLabel.getName())) { | ||
labelsToKeep << nextLabel.getName() | ||
} | ||
} | ||
|
||
issue.setLabels(labelsToKeep as String[]) | ||
} | ||
} |