Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JENKINS-48061] Do something when it's a plain ref
- Loading branch information
Showing
with
15 additions
and
3 deletions.
-
+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())) { |
|
|