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] Introduce GitRefSCMHead
- Loading branch information
|
@@ -809,11 +809,15 @@ public SCMRevision run(GitClient client, String remoteName) throws IOException, |
|
|
context, |
|
|
listener, false); |
|
|
} |
|
|
if (revision.matches("[a-f0-9]{40}")) { |
|
|
return new GitRefSCMRevision(new GitRefSCMHead(revision, revision), revision); |
|
|
} |
|
|
// Pokémon!... Got to catch them all |
|
|
listener.getLogger().printf("Could not find %s in remote references. " |
|
|
+ "Pulling heads to local for deep search...%n", revision); |
|
|
context.wantTags(true); |
|
|
context.wantBranches(true); |
|
|
|
|
|
return doRetrieve(new Retriever<SCMRevision>() { |
|
|
@Override |
|
|
public SCMRevision run(GitClient client, String remoteName) throws IOException, InterruptedException { |
|
|
|
|
@@ -0,0 +1,23 @@ |
|
|
package jenkins.plugins.git; |
|
|
|
|
|
import edu.umd.cs.findbugs.annotations.NonNull; |
|
|
import jenkins.scm.api.SCMHead; |
|
|
import jenkins.scm.api.mixin.SCMHeadMixin; |
|
|
|
|
|
public class GitRefSCMHead extends SCMHead implements SCMHeadMixin { |
|
|
private final String ref; |
|
|
|
|
|
/** |
|
|
* Constructor. |
|
|
* |
|
|
* @param name the name. |
|
|
*/ |
|
|
public GitRefSCMHead(@NonNull String name, String ref) { |
|
|
super(name); |
|
|
this.ref = ref; |
|
|
} |
|
|
|
|
|
public String getRef() { |
|
|
return ref; |
|
|
} |
|
|
} |
|
|
@@ -0,0 +1,8 @@ |
|
|
package jenkins.plugins.git; |
|
|
|
|
|
public class GitRefSCMRevision extends AbstractGitSCMSource.SCMRevisionImpl { |
|
|
|
|
|
public GitRefSCMRevision(GitRefSCMHead head, String hash) { |
|
|
super(head, hash); |
|
|
} |
|
|
} |
|
@@ -514,6 +514,9 @@ public GitSCM build() { |
|
|
extensions.add(new BuildChooserSetting(new AbstractGitSCMSource.SpecificRevisionBuildChooser( |
|
|
(AbstractGitSCMSource.SCMRevisionImpl) revision))); |
|
|
} |
|
|
if (head() instanceof GitRefSCMHead) { |
|
|
withoutRefSpecs().withRefSpec(((GitRefSCMHead) head()).getRef()); |
|
|
} |
|
|
return new GitSCM( |
|
|
asRemoteConfigs(), |
|
|
Collections.singletonList(new BranchSpec(head().getName())), |
|
|
|
@@ -456,7 +456,7 @@ public void retrieveRevision_nonHead() throws Exception { |
|
|
|
|
|
@Issue("JENKINS-48061") |
|
|
@Test |
|
|
@Ignore("Cannot fix until JENKINS-48385 merged") // TODO unignore once JENKINS-48385 |
|
|
@Ignore("At least file:// protocol doesn't allow fetching unannounced commits") |
|
|
public void retrieveRevision_nonAdvertised() throws Exception { |
|
|
sampleRepo.init(); |
|
|
sampleRepo.write("file", "v1"); |
|
@@ -483,7 +483,6 @@ public void retrieveRevision_nonAdvertised() throws Exception { |
|
|
|
|
|
@Issue("JENKINS-48061") |
|
|
@Test |
|
|
@Ignore("Cannot fix until JENKINS-48385 merged") // TODO unignore once JENKINS-48385 |
|
|
public void retrieveRevision_customRef() throws Exception { |
|
|
sampleRepo.init(); |
|
|
sampleRepo.write("file", "v1"); |
|
|