use of org.kohsuke.github.GHLabel in project repairnator by Spirals-Team.
the class EvaluatePotentialBug method computeScore.
private int computeScore(RepairInfo repairInfo) throws IOException {
int score = 0;
GitHub gitHub = GitHubBuilder.fromEnvironment().withOAuthToken(this.githubToken, this.githubLogin).build();
GHRepository ghRepo = gitHub.getRepository(repairInfo.getGithubProject());
String commitMsg = ghRepo.getCommit(repairInfo.getPatchCommit()).getCommitShortInfo().getMessage();
score += this.computeScoreForMessage(commitMsg, 10, 20);
if (repairInfo.getPrId() != null) {
GHPullRequest pullRequest = ghRepo.getPullRequest(Integer.parseInt(repairInfo.getPrId()));
score += this.computeScoreForMessage(pullRequest.getTitle(), 100, 120);
try {
for (GHLabel label : pullRequest.getLabels()) {
score += this.computeScoreForMessage(label.getName(), 100, 120);
}
} catch (HttpException e) {
}
for (GHIssueComment comment : pullRequest.getComments()) {
if (comment.getUser().equals(pullRequest.getUser())) {
score += this.computeScoreForMessage(commitMsg, 10, 20);
} else {
score += this.computeScoreForMessage(commitMsg, 1, 2);
}
}
}
Matcher matcher = ISSUE_PATTERN.matcher(commitMsg);
List<Integer> issuesOrPr = new ArrayList<>();
while (matcher.find()) {
int newIssueOrPRId = Integer.parseInt(matcher.group().substring(1));
issuesOrPr.add(newIssueOrPRId);
}
for (int issueOrPRId : issuesOrPr) {
GHIssue prOrIssue;
try {
prOrIssue = ghRepo.getPullRequest(issueOrPRId);
if (prOrIssue == null) {
prOrIssue = ghRepo.getIssue(issueOrPRId);
}
} catch (Exception e) {
prOrIssue = ghRepo.getIssue(issueOrPRId);
}
if (prOrIssue != null) {
score += this.computeScoreForMessage(prOrIssue.getTitle(), 80, 100);
for (GHIssueComment comment : prOrIssue.getComments()) {
if (comment.getUserName().equals(prOrIssue.getUser().getLogin())) {
score += this.computeScoreForMessage(commitMsg, 10, 20);
} else {
score += this.computeScoreForMessage(commitMsg, 1, 2);
}
}
try {
for (GHLabel label : prOrIssue.getLabels()) {
score += this.computeScoreForMessage(label.getName(), 100, 120);
}
} catch (HttpException e) {
}
}
}
return score;
}
Aggregations