Skip to content

Commit

Permalink
Add a task that will remove github labels from an issue.
Browse files Browse the repository at this point in the history
Refs #7.
  • Loading branch information
jwir3 committed Oct 29, 2016
1 parent 57d7ccc commit 19fa3ad
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
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
}
}
}
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[])
}
}

0 comments on commit 19fa3ad

Please sign in to comment.