public String getDefaultBranchSha() throws IOException { return getReferenceToDefaultBranch().getObject().getSha(); }
/** * Creates reference to the new branch with {@code branch} from default branch. * * @param branchName name of the branch which should be created * @return reference to the new branch * @throws IOException */ public GHRef createBranch(String branchName) throws IOException { GHRef defaultBranch = getReferenceToDefaultBranch(); return ghRepo.createRef("refs/heads/" + branchName, defaultBranch.getObject().getSha()); }
/** * Creates reference to the new tag with {@code tagName} from default branch. * * @param tagName is a name of new tag * @return reference to the new tag * @throws IOException */ public GHRef createTag(String tagName) throws IOException { GHRef defaultBranch = getReferenceToDefaultBranch(); return ghRepo.createRef("refs/tags/" + tagName, defaultBranch.getObject().getSha()); }
@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 org.kohsuke.github.GHCommit getHeadCommitForBranch(final String branch) throws IOException { String sha; final GitBranch gitBranch = new GitBranch(branch); if (gitBranch.isPullRequest()) { try { sha = getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()).getHead().getSha(); } catch (final IOException e) { throw new RuntimeException(e); } } else { try { final GHRef ref = getRef("heads/" + gitBranch); sha = ref.getObject().getSha(); } catch (final IOException e) { sha = gitBranch.toString(); } } return getGithubRepository().getCommit(sha); }