public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException { return getCompare(id1.getSHA1(), id2.getSHA1()); }
public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException { return getCompare(id1.getSHA1(), id2.getSHA1()); }
public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException { return getCompare(id1.getSHA1(), id2.getSHA1()); }
public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException { return getCompare(id1.getName(),id2.getName()); }
GHCompare.Commit[] getComparedCommits(GitHubBranch localBranch, GHBranch remoteBranch) throws IOException { String previous = localBranch.getCommitSha(); String current = remoteBranch.getSHA1(); LOG.debug("Comparing previous hash [{}] with current hash [{}]", previous, current); return remoteBranch.getOwner() .getCompare(previous, current) .getCommits(); }
public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException { GHRepository owner1 = id1.getOwner(); GHRepository owner2 = id2.getOwner(); // If the owner of the branches is different, we have a cross-fork compare. if (owner1!=null && owner2!=null) { String ownerName1 = owner1.getOwnerName(); String ownerName2 = owner2.getOwnerName(); if (!StringUtils.equals(ownerName1, ownerName2)) { String qualifiedName1 = String.format("%s:%s", ownerName1, id1.getName()); String qualifiedName2 = String.format("%s:%s", ownerName2, id2.getName()); return getCompare(qualifiedName1, qualifiedName2); } } return getCompare(id1.getName(), id2.getName()); }
public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException { GHRepository owner1 = id1.getOwner(); GHRepository owner2 = id2.getOwner(); // If the owner of the branches is different, we have a cross-fork compare. if (owner1!=null && owner2!=null) { String ownerName1 = owner1.getOwnerName(); String ownerName2 = owner2.getOwnerName(); if (!StringUtils.equals(ownerName1, ownerName2)) { String qualifiedName1 = String.format("%s:%s", ownerName1, id1.getName()); String qualifiedName2 = String.format("%s:%s", ownerName2, id2.getName()); return getCompare(qualifiedName1, qualifiedName2); } } return getCompare(id1.getName(), id2.getName()); }
private GHCompare getCompare(Build build, Build previousBuild) { try { GitHub gh = GitHubBuilder.fromEnvironment().build(); GHRateLimit rateLimit = gh.getRateLimit(); SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); this.logger.debug("GitHub rate limit: Limit: " + rateLimit.limit + " - Remaining: " + rateLimit.remaining + " - Reset hour: " + dateFormat.format(rateLimit.reset)); if (rateLimit.remaining > 2) { GHRepository ghRepo = gh.getRepository(build.getRepository().getSlug()); GHCommit buildCommit = ghRepo.getCommit(build.getCommit().getSha()); GHCommit previousBuildCommit = ghRepo.getCommit(previousBuild.getCommit().getSha()); GHCompare compare = ghRepo.getCompare(previousBuildCommit, buildCommit); return compare; } else { this.logger.warn("You reached your rate limit for GitHub. You have to wait until " + dateFormat.format(rateLimit.reset) + " to get data. PRInformation will be null for build "+build.getId()+"."); } } catch (IOException e) { this.logger.warn("Error while getting commit from GitHub: " + e); } return null; }