org.eclipse.egit.github.core.Label Java Examples

The following examples show how to use org.eclipse.egit.github.core.Label. 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: LabelServiceEx.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<Label> addLabelsToIssue(String id, String issueId, List<Label> labels)
            throws IOException {
        if (issueId == null) {
            throw new IllegalArgumentException("Issue id cannot be null");
        }
        if (issueId.length() == 0) {
            throw new IllegalArgumentException("Issue id cannot be empty");
        }

//        POST /repos/:owner/:repo/issues/:number/labels

        StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
        uri.append('/').append(id)
                .append(SEGMENT_ISSUES)
                .append('/').append(issueId)
                .append(SEGMENT_LABELS);

        return client.post(uri.toString(), labels, new TypeToken<List<Label>>() {
        }.getType());
    }
 
Example #3
Source File: LabelServiceEx.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param repository
 * @param label      label with edited fields
 * @param name       name of label to edit
 * @return
 * @throws IOException
 */
public Label editLabel(IRepositoryIdProvider repository, Label label, String name)
        throws IOException {
    String repoId = getId(repository);
    if (label == null) {
        throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
    }
    if (name == null) {
        throw new IllegalArgumentException("Label name cannot be null"); //$NON-NLS-1$
    }
    if (name.length() == 0) {
        throw new IllegalArgumentException("Label name cannot be empty"); //$NON-NLS-1$
    }

    StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
    uri.append('/').append(repoId)
            .append(SEGMENT_LABELS)
            .append('/').append(name);

    return client.post(uri.toString(), label, Label.class);
}
 
Example #4
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 #5
Source File: LabelServiceEx.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void deleteLabelFromIssue(IRepositoryIdProvider repository, String issueId,
                                     Label label) throws IOException {

//        Github api format: DELETE /repos/:owner/:repo/issues/:number/labels/:name
        String repoId = getId(repository);
        StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
        uri.append('/').append(repoId)
                .append(SEGMENT_ISSUES)
                .append('/').append(issueId)
                .append('/').append(label.getName());
        client.delete(uri.toString());
    }
 
Example #6
Source File: LabelUpdateService.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected PagedRequest<Label> createUpdatedRequest(IRepositoryIdProvider repoId) {
    PagedRequest<Label> request = super.createUpdatedRequest(repoId);
    request.setType(new TypeToken<Label>() {
    }.getType());
    request.setArrayType(new TypeToken<ArrayList<Label>>() {
    }.getType());
    return request;
}
 
Example #7
Source File: TurboIssue.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TurboIssue(String repoId, Issue issue) {
    this.id = issue.getNumber();
    this.title = issue.getTitle() == null
            ? ""
            : issue.getTitle();
    this.creator = issue.getUser().getLogin();
    this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
    this.isPullRequest = isPullRequest(issue);

    this.description = issue.getBody() == null
            ? ""
            : issue.getBody();
    this.updatedAt = issue.getUpdatedAt() != null ?
            Utility.dateToLocalDateTime(issue.getUpdatedAt()) : this.createdAt;
    this.commentCount = issue.getComments();
    this.isOpen = issue.getState().equals(STATE_OPEN);
    this.assignee = issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
    this.labels = issue.getLabels().stream()
            .map(Label::getName)
            .collect(Collectors.toList());
    this.milestone = issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

    this.metadata = IssueMetadata.empty();
    this.repoId = repoId;
    this.markedReadAt = Optional.empty();
}
 
Example #8
Source File: TurboLabel.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Node getNode() {
    javafx.scene.control.Label node = new javafx.scene.control.Label(shortName);
    node.getStyleClass().add("labels");
    node.setStyle(getStyle());
    if (isInGroup()) {
        Tooltip groupTooltip = new Tooltip(groupName);
        node.setTooltip(groupTooltip);
    }
    return node;
}
 
Example #9
Source File: ReplaceIssueLabelsTask.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    try {
        List<String> responseLabels =
                repo.setLabels(repoId, issueId, labels).stream()
                        .map(Label::getName)
                        .collect(Collectors.toList());
        response.complete(responseLabels.containsAll(labels));
    } catch (IOException e) {
        response.completeExceptionally(e);
    }
}
 
Example #10
Source File: TurboLabelTest.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void labelRepoId() {
    Label label = new Label();
    label.setName("test label");
    label.setColor("ffffff");
    TurboLabel turboLabel = new TurboLabel("dummy/dummy", label);
    assertEquals("dummy/dummy", turboLabel.getRepoId());

}
 
Example #11
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 #12
Source File: LabelServiceEx.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<Label> addLabelsToIssue(IRepositoryIdProvider repository,
                                    String issueId, List<Label> labels) throws IOException {
    String repoId = getId(repository);
    return addLabelsToIssue(repoId, issueId, labels);
}
 
Example #13
Source File: TurboLabel.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TurboLabel(String repoId, Label label) {
    this(repoId, label.getColor(), label.getName());
}
 
Example #14
Source File: Repo.java    From HubTurbo with GNU Lesser General Public License v3.0 votes vote down vote up
List<Label> setLabels(String repoId, int issueId, List<String> labels) throws IOException;