diff --git a/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/ListGithubIssuesTask.groovy b/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/ListGithubIssuesTask.groovy new file mode 100644 index 0000000..f4817a7 --- /dev/null +++ b/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/ListGithubIssuesTask.groovy @@ -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 + } + } +} diff --git a/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/RemoveLabelsFromGithubIssueTask.groovy b/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/RemoveLabelsFromGithubIssueTask.groovy new file mode 100644 index 0000000..3c4af28 --- /dev/null +++ b/gruel/src/main/groovy/com/glasstowerstudios/gruel/tasks/github/RemoveLabelsFromGithubIssueTask.groovy @@ -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 labels; + + void setIssueNumber(int issueNumber) { + this.issueNumber = issueNumber; + } + + void setLabels(List labels) { + this.labels = labels; + } + + List 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[]) + } +}