@Override public long lastModified() throws IOException, InterruptedException { return commit.getCommitDate().getTime(); }
@Override public long lastModified() { Object rd = revision.getRemoteData(); if (rd instanceof GHPullRequest) { GHPullRequest pr = (GHPullRequest) rd; if (pr != null) { try { return pr.getUpdatedAt().getTime(); } catch (IOException e) { // never thrown } } } try { return commit().getCommitDate().getTime(); } catch (IOException e) { return 0L; } }
@Override public long lastModified() { if (repo == null) { return 0L; } synchronized (this) { if (!open) { return 0L; } } if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl) { try { GHCommit commit = repo.getCommit(((AbstractGitSCMSource.SCMRevisionImpl) revision).getHash()); return commit.getCommitDate().getTime(); } catch (IOException e) { // ignore } } else if (revision == null) { try { GHRef ref = repo.getRef(this.ref); GHCommit commit = repo.getCommit(ref.getObject().getSha()); return commit.getCommitDate().getTime(); } catch (IOException e) { // ignore } } return 0; }
public Optional<CommitDetails> getCommitDetails(String githubRepo, String sha) { try { logger.info("Getting commit details for sha {} on url {}", sha, githubRepo); GHCommit commit = gitHub.getRepository(githubRepo).getCommit(sha); GHUser author = commit.getAuthor(); String committerName = (author == null) ? null : author.getName(); if (committerName == null || committerName.isEmpty()) { committerName = author.getLogin(); } CommitDetails commitDetails = new CommitDetails(sha, commit.getHtmlUrl().toString(), commit.getCommitShortInfo().getMessage(), commit.getCommitDate(), commit.getLastStatus(), author.getAvatarUrl(), committerName); return Optional.of(commitDetails); } catch (IOException e) { logger.warn("Could not get commit details from Github!", e); return Optional.empty(); } }
private Commit createCommitForMetrics(PullRequest prInformation, boolean base) { Commit commit = new Commit(); GHCommitPointer ghCommitPointer; GHCommit ghCommit; if (base) { ghCommitPointer = prInformation.getBaseRef(); } else { ghCommitPointer = prInformation.getHeadRef(); } try { ghCommit = ghCommitPointer.getCommit(); String branchLabel = ghCommitPointer.getLabel(); String branchName = branchLabel.substring(branchLabel.indexOf(":") + 1, branchLabel.length()); commit.setRepoName(ghCommitPointer.getRepository().getFullName()); commit.setBranchName(branchName); commit.setSha(ghCommit.getSHA1()); commit.setUrl(ghCommit.getHtmlUrl().toString()); commit.setDate(ghCommit.getCommitDate()); return commit; } catch (IOException e) { this.addStepError("Exception while writing properties related to commits.", e); } return null; }