/** * Resolves the parent commit objects and return them. */ public List<GHCommit> getParents() throws IOException { List<GHCommit> r = new ArrayList<GHCommit>(); for (String sha1 : getParentSHA1s()) r.add(owner.getCommit(sha1)); return r; }
/** * Resolves the parent commit objects and return them. */ public List<GHCommit> getParents() throws IOException { List<GHCommit> r = new ArrayList<GHCommit>(); for (String sha1 : getParentSHA1s()) r.add(owner.getCommit(sha1)); return r; }
/** * Resolves the parent commit objects and return them. */ public List<GHCommit> getParents() throws IOException { List<GHCommit> r = new ArrayList<GHCommit>(); for (String sha1 : getParentSHA1s()) r.add(owner.getCommit(sha1)); return r; }
private String getParentSha(final GHCommit commit, final GitBranch gitBranch) throws IOException { final String parentSha; if (gitBranch.isPullRequest()) { final GHPullRequest pullRequest = this.githubRepositoryService.getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()); parentSha = pullRequest.getBase().getSha(); } else { parentSha = (commit.getParentSHA1s() != null && commit.getParentSHA1s().size() > 0) ? commit.getParentSHA1s().get(0) : null; } return parentSha; }
public DotCiUpstreamTriggerCause(DynamicBuild sourceBuild, DynamicProject targetJob, Map<String, String> jobOptions) { branch = new GitBranch(jobOptions.get("BRANCH")); GHCommit commit; if (jobOptions.containsKey("SHA")) { commit = getCommitFromSha(targetJob, jobOptions.get("SHA")); } else { commit = getHeadCommitForBranch(targetJob, branch.toString()); } this.pusher = sourceBuild.getCause().getPusher(); this.description = "Started by upstream job " + sourceBuild.getParent().getFullDisplayName() + ".: " + sourceBuild.getNumber(); this.sha = commit.getSHA1(); this.parentSha = commit.getParentSHA1s().size() > 0 ? commit.getParentSHA1s().get(0) : null; this.commitInfo = new CommitInfo(commit, branch); }
private String getLastKnowParent(GitHub gh, GHRepository ghRepo, Git git, String oldCommitSha, AbstractStep step) throws IOException { showGitHubRateInformation(gh, step); GHCommit commit = ghRepo.getCommit(oldCommitSha); // get the deleted // commit from GH List<String> commitParents = commit.getParentSHA1s(); if (commitParents.isEmpty()) { step.addStepError("The following commit does not have any parent in GitHub: " + oldCommitSha + ". It cannot be resolved."); return null; } if (commitParents.size() > 1) { this.getLogger().debug("Step " + step.getName() + " - The commit has more than one parent : " + commit.getHtmlUrl()); } String parent = commitParents.get(0); try { ObjectId commitObject = git.getRepository().resolve(parent); git.getRepository().open(commitObject); return parent; } catch (MissingObjectException e) { return getLastKnowParent(gh, ghRepo, git, parent, step); } }