/** * Turns collected information of an error into a new (offline) GitHub issue * * @param details 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(LinkedHashMap<String, String> details) { String errorMessage = details.get("error.message"); if (errorMessage == null || errorMessage.isEmpty()) { errorMessage = "Unspecified error"; } details.remove("error.message"); String errorHash = details.get("error.hash"); if (errorHash == null) { errorHash = ""; } details.remove("error.hash"); final Issue gitHubIssue = new Issue(); final String body = generateGitHubIssueBody(details, true); gitHubIssue.setTitle(ErrorReportBundle.message("git.issue.title", errorHash, errorMessage)); gitHubIssue.setBody(body); Label label = new Label(); label.setName(issueLabel); gitHubIssue.setLabels(Collections.singletonList(label)); return gitHubIssue; }
/** * Edit issue * * @param repoId * @param repository * @param issue * @return created issue * @throws IOException */ private Issue editIssue(String repoId, Issue issue) throws IOException { if (issue == null) throw new IllegalArgumentException("Issue cannot be null"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(repoId); uri.append(SEGMENT_ISSUES); uri.append('/').append(issue.getNumber()); Map<Object, Object> params = createIssueMap(issue, false); String state = issue.getState(); if (state != null) params.put(FILTER_STATE, state); return client.post(uri.toString(), params, Issue.class); }
Map<Object, Object> params = new HashMap<Object, Object>(); if (issue != null) { params.put(FIELD_BODY, issue.getBody()); params.put(FIELD_TITLE, issue.getTitle()); User assignee = issue.getAssignee(); if (assignee != null) params.put(FILTER_ASSIGNEE, assignee.getLogin()); Milestone milestone = issue.getMilestone(); if (milestone != null) { int number = milestone.getNumber(); List<Label> labels = issue.getLabels(); if (labels != null) { List<String> labelNames = new ArrayList<String>(labels.size());
public void process(Exchange exchange) throws Exception { Issue issue = new Issue(); String issueTitle = exchange.getIn().getHeader(GitHubConstants.GITHUB_ISSUE_TITLE, String.class); if (ObjectHelper.isEmpty(issueTitle)) { throw new IllegalArgumentException("Issue Title must be specified to create an issue"); } issue.setTitle(issueTitle); issue.setBody(exchange.getIn().getBody(String.class)); Issue finalIssue = issueService.createIssue(getRepository(), issue); // copy the header of in message to the out message exchange.getOut().copyFrom(exchange.getIn()); exchange.getOut().setBody(finalIssue); }
log.warn("Issue: {}", issue); Vertex issuenode = getOrCreateIssue(reponame, issue); if (issue.getAssignee() != null) { setProperty(issuenode, PropertyName.ASSIGNEE, issue.getAssignee().getLogin()); Vertex userNode = getOrCreateUser(issue.getAssignee()); createEdgeIfNotExist(userNode, issuenode, EdgeType.ISSUEASSIGNEE); setProperty(issuenode, PropertyName.BODY, issue.getBody()); setProperty(issuenode, PropertyName.BODY_HTML, issue.getBodyHtml()); setProperty(issuenode, PropertyName.CLOSED_AT, issue.getClosedAt()); setProperty(issuenode, PropertyName.COMMENTS, issue.getComments()); setProperty(issuenode, PropertyName.CREATED_AT, issue.getCreatedAt()); setProperty(issuenode, PropertyName.HTML_URL, issue.getHtmlUrl()); setProperty(issuenode, PropertyName.HTML_URL, issue.getHtmlUrl()); setProperty(issuenode, PropertyName.GITHUB_ID, issue.getId()); for (Label label : issue.getLabels()) { Vertex labelnode = getOrCreateIssueLabel(label); createEdgeIfNotExist(issuenode, labelnode, EdgeType.ISSUELABEL); setProperty(issuenode, PropertyName.GITHUB_ID, issue.getId()); if (issue.getMilestone() != null) { if (repo != null) { Milestone milestone = issue.getMilestone(); Vertex msVtx = saveMilestone(repo, milestone); createEdgeIfNotExist(issuenode, msVtx, EdgeType.MILESTONE); setProperty(issuenode, PropertyName.NUMBER, issue.getNumber()); if (issue.getPullRequest() != null && issue.getPullRequest().getId() != 0L) {
issue.getHtmlUrl(), issue.getTitle(), issue.getBodyText(), issue.getBodyHtml(), toUser(issue.getAssignee()), toLabels(issue.getLabels()), toState(issue.getState()), toMilestone(repository, issue.getMilestone()), toDateTime(issue.getCreatedAt()), toDateTime(issue.getUpdatedAt()), toDateTime(issue.getClosedAt()) );
Issue duplicate = findFirstDuplicate(newGibHubIssue.getTitle(), issueService, repoID); boolean isNewIssue = true; if (duplicate != null) { issueService.createComment(repoID, duplicate.getNumber(), generateGitHubIssueBody(environmentDetails, false)); newGibHubIssue = duplicate; isNewIssue = false; final long id = newGibHubIssue.getNumber(); final String htmlUrl = newGibHubIssue.getHtmlUrl(); final String message = ErrorReportBundle.message(isNewIssue ? "git.issue.text" : "git.issue.duplicate.text", htmlUrl, id); result = new SubmittedReportInfo(htmlUrl, message, isNewIssue ? SubmissionStatus.NEW_ISSUE : SubmissionStatus.DUPLICATE);
public List<Comment> getIssueComments(final IRepositoryIdProvider repo, final Issue issue) { return getComments(repo, issue.getNumber()); }
/** * Collects all issues on the repo and finds the first duplicate that has the same title. For this to work, the title * contains the hash of the stack trace. * * @param uniqueTitle Title of the newly created issue. Since for auto-reported issues the title is always the same, * it includes the hash of the stack trace. The title is used so that I don't have to match * something in the whole body of the issue. * @param service Issue-service of the GitHub lib that lets you access all issues * @param repo The repository that should be used * @return The duplicate if one is found or null * @throws IOException Problems when connecting to GitHub */ @Nullable private static Issue findFirstDuplicate(String uniqueTitle, final IssueService service, RepositoryId repo) throws IOException { Map<String, String> searchParameters = new HashMap<>(2); searchParameters.put(IssueService.FILTER_STATE, IssueService.STATE_OPEN); final PageIterator<Issue> pages = service.pageIssues(repo, searchParameters); for (Collection<Issue> page : pages) { for (Issue issue : page) { if (issue.getTitle().equals(uniqueTitle)) { return issue; } } } return null; }
@Override @Result protected String doInBackground(Void... params) { GitHubClient client; if (login.shouldUseApiToken()) { client = new GitHubClient().setOAuth2Token(login.getApiToken()); } else { client = new GitHubClient().setCredentials(login.getUsername(), login.getPassword()); } Issue issue = new Issue().setTitle(report.getTitle()).setBody(report.getDescription()); try { new IssueService(client).createIssue(target.getUsername(), target.getRepository(), issue); return RESULT_OK; } catch (RequestException e) { switch (e.getStatus()) { case STATUS_BAD_CREDENTIALS: if (login.shouldUseApiToken()) return RESULT_INVALID_TOKEN; return RESULT_BAD_CREDENTIALS; case STATUS_ISSUES_NOT_ENABLED: return RESULT_ISSUES_NOT_ENABLED; default: e.printStackTrace(); return RESULT_UNKNOWN; } } catch (IOException e) { e.printStackTrace(); return RESULT_UNKNOWN; } }
private Vertex getOrCreateIssue(final String project, final Issue issue) { final String issueId = project + ":" + issue.getNumber(); return getOrCreateVertexHelper(IdCols.ISSUE, issueId, VertexType.ISSUE, issueidx); }
@Override public ExecutionDecision resolve() { Validate.notNull(gitHubIssue, "GitHub issue must be specified."); Validate.notNull(annotation, "Annotation must be specified."); // Execute test if detector failed because GitHub issue is not related to specified environment. if (!(new DetectorProcessor().process(annotation))) { return ExecutionDecision.execute(); } final String gitHubStatus = gitHubIssue.getState(); if (gitHubStatus == null || gitHubStatus.length() == 0) { return ExecutionDecision.execute(); } if (annotation.force()) { return ExecutionDecision.execute(FORCING_EXECUTION_REASON_STRING); } if (gitHubGovernorConfiguration.getForce()) { return ExecutionDecision.execute(FORCING_EXECUTION_REASON_STRING); } if (gitHubStatus.equals(GITHUB_CLOSED_STRING)) { return ExecutionDecision.execute(); } return ExecutionDecision.dontExecute(String.format(SKIPPING_EXECUTION_REASON_STRING, gitHubIssue.getNumber(), gitHubStatus)); }
public Collection<IssueEvent> getIssueEvents(final IRepositoryIdProvider repo, final Issue issue) { Collection<IssueEvent> events = null; try { events = service.getIssueEvents(repo, issue); } catch (IOException e) { log.error("Exception fetching events for issue {}:{}", new Object[]{repo.generateId(), issue.getNumber(), e}); } return events; } }
private Vertex getOrCreateIssue(final Repository repo, final Issue issue) { final String issueId = repo.generateId() + ":" + issue.getNumber(); return getOrCreateVertexHelper(IdCols.ISSUE, issueId, VertexType.ISSUE, issueidx); }
/** * {@link #saveRepositoryIssues(String, Collection)} modified for v3 api * * @param repo * @param issues * @return */ public Map<String, Vertex> saveRepositoryIssues( final Repository repo, final Collection<Issue> issues) { final Vertex proj = getOrCreateRepository(repo); final HashMap<String,Vertex> mapper = new HashMap<String,Vertex>(); for (Issue issue : issues) { String issueId = repo.generateId() + ":" + issue.getNumber(); Vertex issuenode = saveIssue(repo, issue); createEdgeIfNotExist(null, proj, issuenode, EdgeType.ISSUE); mapper.put(issueId, issuenode); } return mapper; }
String issueId = repo.generateId() + ":" + issue.getNumber(); if (!needsUpdate(savedIssues.get(issue.getNumber()), true)) { log.debug("Skipping fetching comments for issue {} - recently updated {}", issueId, savedIssues.get(issue.getNumber())); continue; log.debug("Pulling comments for issue: {} - last update: {}", issueId, savedIssues.get(issue.getNumber())); try { String issueId = repo.generateId() + ":" + issue.getNumber(); if (!needsUpdate(savedIssues.get(issue.getNumber()), true)) { log.debug("Skipping fetching events for issue {} - recently updated - {}", new Object[]{issueId, savedIssues.get(issue.getNumber())}); continue; } else { log.warn("issue {} - last updated: {}", issue.getNumber(), savedIssues.get(issue.getNumber())); log.debug("Pulling events for issue: {} - {}", new Object[]{issueId, savedIssues.get(issue.getNumber())}); try { Collection<IssueEvent> evts = imv3.getIssueEvents(repo, issue);