Skip to content
Permalink
Browse files

[FIXED JENKINS-42278] SCMProbeImpl.stat was returning REGULAR_FILE bu…

…t failing rather than return NONEXISTENT.
  • Loading branch information...
jglick committed Aug 15, 2017
1 parent fd83e27 commit 4b49070979d49d5c263bcd92ae7b57f4eb83eaa2
@@ -446,16 +446,8 @@ public SCMProbeImpl(HgExe hg, FilePath cache, TaskListener listener, MercurialRe
public @Nonnull
SCMProbeStat stat(@Nonnull String path) throws IOException {
try {
String files = hg.popen(cache, listener, true,
new ArgumentListBuilder("locate",
"-r",
revision.getHash(),
"-I",
"path:" + path));
if (StringUtils.isBlank(files)) {
return SCMProbeStat.fromType(SCMFile.Type.NONEXISTENT);
}
return SCMProbeStat.fromType(SCMFile.Type.REGULAR_FILE);
return SCMProbeStat.fromType(hg.run("locate", "-r", revision.getHash(), "-I", "path:" + path).
pwd(cache).join() == 0 ? SCMFile.Type.REGULAR_FILE : SCMFile.Type.NONEXISTENT);
} catch (InterruptedException e) {
throw new IOException(e);
}
@@ -62,6 +62,7 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

public class PipelineTest {
@@ -145,6 +146,7 @@
assertFalse(iterator.hasNext());
}

@Issue("JENKINS-42278")
@Test public void exactRevisionMercurial() throws Exception {
// TODO mostly pointless to use MercurialContainer here since multibranch requires a caching installation and thus for hg to be installed on master
FilePath sampleRepo = new FilePath(tmp.getRoot());
@@ -155,12 +157,18 @@
sampleRepo.child("Jenkinsfile").write("echo hudson.model.Items.XSTREAM2.toXML(scm); semaphore 'wait'; node {checkout scm; echo readFile('file')}", null);
sampleRepo.child("file").write("initial content", null);
m.hg(sampleRepo, "commit", "--addremove", "--message=flow");
m.hg(sampleRepo, "update", "null");
m.hg(sampleRepo, "branch", "docs");
sampleRepo.child("README").write("Just docs here!", null);
m.hg(sampleRepo, "commit", "--message=unrelated branch, not buildable");
m.hg(sampleRepo, "update", "default");
WorkflowMultiBranchProject mp = r.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
String instName = "caching";
r.jenkins.getDescriptorByType(MercurialInstallation.DescriptorImpl.class).setInstallations(
new MercurialInstallation(instName, "", "hg", false, true, false, null, null));
mp.getSourcesList().add(new BranchSource(new MercurialSCMSource(null, instName, sampleRepo.toURI().toString(), null, null, null, null, null, true)));
WorkflowJob p = scheduleAndFindBranchProject(mp, "default");
assertEquals(1, mp.getItems().size());
SemaphoreStep.waitForStart("wait/1", null);
WorkflowRun b1 = p.getLastBuild();
assertNotNull(b1);

0 comments on commit 4b49070

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