Search in sources :

Example 6 with GHIssue

use of org.kohsuke.github.GHIssue in project Rubicon by Rubicon-Bot.

the class CommandGitBug method handle.

public static void handle(MessageReceivedEvent event) {
    if (!reportMap.containsKey(event.getAuthor().getIdLong())) {
        return;
    }
    ReportHolder reportHolder = reportMap.get(event.getAuthor().getIdLong());
    if (event.getMessage().getContentDisplay().contains(reportHolder.title))
        return;
    if (!event.getTextChannel().getId().equals(reportHolder.textChannel.getId()))
        return;
    String description = event.getMessage().getContentDisplay();
    try {
        GitHub gitHub = GitHub.connectUsingOAuth(Info.GITHUB_TOKEN);
        GHRepository repository = gitHub.getOrganization("Rubicon-Bot").getRepository("Rubicon");
        GHIssue issue = repository.createIssue(reportHolder.title).body(ISSUE_HEADER + event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + ISSUE_SUFFIX + description).label("Bug").label("Requires Testing").create();
        reportHolder.delete(issue.getHtmlUrl().toString());
        event.getMessage().delete().queue();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) GHIssue(org.kohsuke.github.GHIssue) IOException(java.io.IOException)

Example 7 with GHIssue

use of org.kohsuke.github.GHIssue in project contribution by checkstyle.

the class TemplateProcessorTest method getMockReleasenotesMessages.

private static List<ReleaseNotesMessage> getMockReleasenotesMessages() throws NoSuchFieldException, IllegalAccessException {
    final List<ReleaseNotesMessage> messages = new ArrayList<>();
    final ReleaseNotesMessage msgWithoutIssueNo = new ReleaseNotesMessage("Mock issue title 1", "Author 1");
    messages.add(msgWithoutIssueNo);
    final ReleaseNotesMessage msgWithoutIssueNoWithMultipleAuthors = new ReleaseNotesMessage("Mock issue title 2", "Author 3, Author 4");
    messages.add(msgWithoutIssueNoWithMultipleAuthors);
    final GHIssue issue1 = getMockGithubIssue(123, "Mock issue title 3");
    final ReleaseNotesMessage msgWithIssueNo = new ReleaseNotesMessage(issue1, "Author 5");
    messages.add(msgWithIssueNo);
    final GHIssue issue2 = getMockGithubIssue(123, "Mock issue title 4");
    final ReleaseNotesMessage msgWithIssueNoWithMultipleAuthors = new ReleaseNotesMessage(issue2, "Author 6, Author 7");
    messages.add(msgWithIssueNoWithMultipleAuthors);
    return messages;
}
Also used : ArrayList(java.util.ArrayList) GHIssue(org.kohsuke.github.GHIssue)

Aggregations

GHIssue (org.kohsuke.github.GHIssue)7 IOException (java.io.IOException)4 GHRepository (org.kohsuke.github.GHRepository)3 GitHub (org.kohsuke.github.GitHub)3 ArrayList (java.util.ArrayList)2 Field (java.lang.reflect.Field)1 PathMatcher (java.nio.file.PathMatcher)1 HashSet (java.util.HashSet)1 Matcher (java.util.regex.Matcher)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 ParseException (org.json.simple.parser.ParseException)1 GHIssueComment (org.kohsuke.github.GHIssueComment)1 GHLabel (org.kohsuke.github.GHLabel)1 GHPullRequest (org.kohsuke.github.GHPullRequest)1 HttpException (org.kohsuke.github.HttpException)1 URunnable (xyz.derkades.ublisk.utils.URunnable)1