Java Code Examples for org.eclipse.egit.github.core.Issue#setLabels()

The following examples show how to use org.eclipse.egit.github.core.Issue#setLabels() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnonymousFeedback.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
/**
 * Turns collected information of an error into a new (offline) GitHub issue
 *
 * @param errorReportInformation a map of the information. Note that I remove items from there when they should not go in the issue
 *                               body as well. When creating the body, all remaining items are iterated.
 * @return the new issue
 */
private static Issue createNewGibHubIssue(ErrorReportInformation errorReportInformation) {
    String errorMessage = errorReportInformation.get(ERROR_MESSAGE);
    if (errorMessage == null || errorMessage.isEmpty()) {
        errorMessage = "Unspecified error";
    }
    String errorHash = errorReportInformation.get(ERROR_HASH);
    if (errorHash == null) {
        errorHash = "";
    }

    final Issue gitHubIssue = new Issue();
    final String body = generateGitHubIssueBody(errorReportInformation);
    gitHubIssue.setTitle(String.format(GIT_ISSUE_TITLE, errorHash, errorMessage));
    gitHubIssue.setBody(body);
    Label bugLabel = new Label();
    bugLabel.setName(ISSUE_LABEL_BUG);
    Label autoGeneratedLabel = new Label();
    autoGeneratedLabel.setName(ISSUE_LABEL_AUTO_GENERATED);
    gitHubIssue.setLabels(Arrays.asList(autoGeneratedLabel, bugLabel));
    return gitHubIssue;
}
 
Example 2
Source File: TurboIssueTests.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void turboIssueTest() {
    Issue issue = new Issue();
    issue.setNumber(1);
    issue.setUser(new User().setLogin("test_user"));
    issue.setCreatedAt(new Date());
    issue.setUpdatedAt(new Date());
    issue.setState("open");
    ArrayList<Label> labels = new ArrayList<>();
    labels.add(new Label().setName("test label"));
    issue.setLabels(labels);
    TurboIssue turboIssue = new TurboIssue("dummy/dummy", issue);
    assertEquals(1, turboIssue.getId());
    assertEquals("test_user", turboIssue.getCreator());
    assertEquals(true, turboIssue.isOpen());
    assertEquals("test label", turboIssue.getLabels().get(0));
}
 
Example 3
Source File: GenerateRoadmapIssuesTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void createIssuesStepB() throws Exception {

    String accessToken = System.getenv("GitHubAccessToken");
    Assume.assumeNotNull("GitHubAccessToken not null", accessToken);

    GitHubClient client = new GitHubClient();
    client.setOAuth2Token(accessToken);

    String githubUser = "wildfly-extras";
    String githubRepo = "wildfly-camel";

    Milestone milestone = null;
    MilestoneService milestoneService = new MilestoneService(client);
    for (Milestone aux : milestoneService.getMilestones(githubUser, githubRepo, IssueService.STATE_OPEN)) {
        if  (aux.getTitle().equals(MILESTONE)) {
            milestone = aux;
            break;
        }
    }
    Assert.assertNotNull("Milestone not null", milestone);

    IssueService issueService = new IssueService(client);
    try (BufferedReader br = new BufferedReader(new FileReader(auxfile.toFile()))) {
        String line = br.readLine();
        while (line != null) {
            String title = "Add support for " + line;
            System.out.println(title);
            Issue issue = new Issue();
            issue.setTitle(title);
            issue.setLabels(Collections.singletonList(LABEL));
            issue.setMilestone(milestone);
            issueService.createIssue(githubUser, githubRepo, issue);
            line = br.readLine();
            Thread.sleep(3 * 1000);
        }
    }
}
 
Example 4
Source File: IssueReportFix.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Creates a {@link Issue} object.
 * 
 * @param issueTitle issue title
 * @param issueText issue description
 * @param attachmentIndex index of selected attachment
 * @param attachment error Java and Jimple code
 * @throws CoreException
 */
private void createIssue(String issueTitle, String issueText, int attachmentIndex, String attachment) throws CoreException {

	Issue issue = new Issue();

	if (issueTitle.trim().isEmpty()) {
		issueTitle = "Bug Report";
	}
	issue.setTitle(issueTitle);

	Label bugLabel = new Label();
	bugLabel.setName("bug");
	Label feedBackLabel = new Label();
	feedBackLabel.setName("UserFeedback");
	Label sastLabel = new Label();
	sastLabel.setName("SAST");
	ArrayList<Label> labelList = new ArrayList<>();
	labelList.add(bugLabel);
	labelList.add(feedBackLabel);
	labelList.add(sastLabel);
	issue.setLabels(labelList);

	StringBuilder builder = new StringBuilder();
	builder.append("**User Issue Description**\n");
	builder.append(issueText + "\n\n");
	builder.append("**Configuration:**\n");
	builder.append("- Eclipse version: " + Platform.getBundle("org.eclipse.platform").getVersion() + Constants.lineSeparator);
	builder.append("- Java version: " + System.getProperty("java.version") + Constants.lineSeparator);
	builder.append("- OS: " + System.getProperty("os.name").toLowerCase() + Constants.lineSeparator+ Constants.lineSeparator);
	builder.append("**CogniCrypt Error Information:**" + Constants.lineSeparator);
	builder.append("- Violated CrySL rule: " + (String) marker.getAttribute("crySLRuleName") + Constants.lineSeparator);
	builder.append("- Error type: " + QuickFixUtils.getErrorTypeFromMarkerType((String) marker.getAttribute("errorType")) + Constants.lineSeparator);
	builder.append("- Error message: " + (String) marker.getAttribute(IMarker.MESSAGE) + Constants.lineSeparator);
	builder.append("- Severity: " + Severities.get((int) marker.getAttribute(IMarker.SEVERITY)).toString() + Constants.lineSeparator + Constants.lineSeparator);

	if (!attachment.isEmpty()) {
		builder.append("**Java Code**\n\n");
		builder.append("Error line: `" + getErrorLineCode() + "`" + Constants.lineSeparator);
		builder.append("```java\n" + attachment + Constants.lineSeparator +"```");
		builder.append("\n\n");

		if (attachmentIndex == 1 || attachmentIndex == 0) {
			builder.append("**Jimple Code**\n\n");
			builder.append("```java\n" + (String) marker.getAttribute("errorJimpleCode") + "```");
			builder.append("\n\n");
		}

	}

	String body = builder.toString();
	issue.setBody(body);

	send(issue);
}
 
Example 5
Source File: GitHubExporter.java    From rtc2jira with GNU General Public License v2.0 4 votes vote down vote up
private Issue createIssueFromWorkItem(ODocument workItem) throws IOException {
  Issue issue = new Issue();
  for (Entry<String, Object> entry : workItem) {
    String field = entry.getKey();
    switch (field) {
      case ID:
        String id = (String) entry.getValue();
        issue.setNumber(Integer.valueOf(id));
        break;
      case SUMMARY:
        String summary = (String) entry.getValue();
        issue.setTitle(summary);
        break;
      case DESCRIPTION:
        String htmlText = (String) entry.getValue();
        issue.setBody(htmlText);
        break;
      case WORK_ITEM_TYPE:
        String workitemType = (String) entry.getValue();
        switch (workitemType) {
          case TASK:
            issue.setLabels(Collections.singletonList(getLabel("Task")));
            break;
          case STORY:
            issue.setLabels(Collections.singletonList(getLabel("Story")));
            break;
          case EPIC:
            issue.setLabels(Collections.singletonList(getLabel("Epic")));
            break;
          case BUSINESSNEED:
            issue.setLabels(Collections.singletonList(getLabel("Business Need")));
            break;
          case DEFECT:
            issue.setLabels(Collections.singletonList(getLabel("Defect")));
            break;
          default:
            LOGGER.warning("Cannot create label for unknown workitemType: " + workitemType);
            break;
        }
        break;
      default:
        break;
    }
  }
  issue.setTitle(issue.getNumber() + ": " + issue.getTitle());
  int existingGitHubIssueNumber = StorageQuery.getField(workItem, FieldNames.GITHUB_WORKITEM_LINK, 0);
  issue.setNumber(existingGitHubIssueNumber);
  return issue;
}