Skip to content
Permalink
Browse files

[JENKINS-48061] Do something when it's a plain ref

  • Loading branch information...
rsandell committed Mar 23, 2018
1 parent 5411589 commit ac97524ab61e1cd2caf4ef9e1419bc410f3c0658
Showing with 15 additions and 3 deletions.
  1. +15 −3 src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
@@ -360,16 +360,19 @@ protected GitTool resolveGitTool(String gitTool) {
*/
@CheckForNull
@Override
protected SCMRevision retrieve(@NonNull final SCMHead head, @NonNull TaskListener listener)
protected SCMRevision retrieve(@NonNull final SCMHead head, @NonNull final TaskListener listener)
throws IOException, InterruptedException {
final GitSCMSourceContext context = new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits());
GitSCMSourceContext context = new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits());
GitSCMTelescope telescope = GitSCMTelescope.of(this);
if (telescope != null) {
String remote = getRemote();
StandardUsernameCredentials credentials = getCredentials();
telescope.validate(remote, credentials);
return telescope.getRevision(remote, credentials, head);
}
if (head instanceof GitSCMHeadMixin) {
context = context.withoutRefSpecs().withRefSpec(((GitSCMHeadMixin) head).getRef());
}
return doRetrieve(new Retriever<SCMRevision>() {
@Override
public SCMRevision run(GitClient client, String remoteName) throws IOException, InterruptedException {
@@ -388,7 +391,16 @@ public SCMRevision run(GitClient client, String remoteName) throws IOException,
return new GitBranchSCMRevision((GitBranchSCMHead)head, b.getSHA1String());
}
}
} else { //TODO change to something
} else if (head instanceof GitRefSCMHead) {
try {
ObjectId objectId = client.revParse(((GitRefSCMHead) head).getRef());
return new GitRefSCMRevision((GitRefSCMHead)head, objectId.name());
} catch (GitException e) {
// ref could not be found
return null;
}
} else {
listener.getLogger().println("Entering default git retrieve code path");
for (Branch b : client.getRemoteBranches()) {
String branchName = StringUtils.removeStart(b.getName(), remoteName + "/");
if (branchName.equals(head.getName())) {

0 comments on commit ac97524

Please sign in to comment.
You can’t perform that action at this time.