use of org.kohsuke.github.GHRepository in project Robot by fo0.
the class UpdateUtils method isAvailable.
public static boolean isAvailable() {
try {
GitHub gitHub = GitHub.connectAnonymously();
GHRepository repository = gitHub.getRepository(CONSTANTS.GITHUB_URI);
GHRelease latest = repository.getLatestRelease();
boolean newerVersionAvailable = new Semver(latest.getTagName().replaceAll("v", "")).isGreaterThan(new Semver(CONSTANTS.VERSION));
if (!newerVersionAvailable) {
Logger.info("no newer version available, skipping now");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
return false;
} else {
Logger.info("detected new version");
Logger.info("current version: " + CONSTANTS.VERSION);
Logger.info("latest version: " + latest.getTagName().replaceAll("v", ""));
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
use of org.kohsuke.github.GHRepository in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getTree.
@Override
@Cacheable(value = "github-tree")
public GHTree getTree() {
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
return repo.getTreeRecursive(githubDocBranch, 1);
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("Documentation not available, sorry for the inconvenience");
}
}
use of org.kohsuke.github.GHRepository in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getPage.
@Override
@Cacheable(value = "github-pages")
public String getPage(String folder, String page) {
String finalPage = page;
if ("news".equalsIgnoreCase(folder)) {
finalPage = getCorrespondingPageForNews(page);
}
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
GHContent content = null;
String extension = ".md";
if (folder.contains("json")) {
// if folder contains json
extension = ".json";
}
content = repo.getFileContent(folder + "/" + finalPage + extension, githubDocBranch);
return content.getContent();
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("Documentation not available, sorry for the inconvenience");
}
}
use of org.kohsuke.github.GHRepository 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;
}
use of org.kohsuke.github.GHRepository in project faber by mkuschov.
the class GitLoader method GetWatchedReposTrees.
public HashMap<GHRepository, HashMap<GHBranch, GHTree>> GetWatchedReposTrees() {
HashMap<GHRepository, HashMap<GHBranch, GHTree>> watchedReposTrees = new HashMap<>();
this.watchedRepos.forEach(i -> {
HashMap<GHBranch, GHTree> tmp = new HashMap<>();
try {
i.getBranches().forEach((name, branch) -> {
try {
GHTree urlToBracnhTree = i.getTreeRecursive(branch.getSHA1(), 1);
tmp.put(branch, urlToBracnhTree);
System.out.println(i.getName() + " " + branch.getName() + " " + urlToBracnhTree.toString());
} catch (IOException e) {
e.printStackTrace();
}
});
watchedReposTrees.put(i, tmp);
} catch (IOException e) {
e.printStackTrace();
}
});
return watchedReposTrees;
}
Aggregations