Skip to content
Browse files

[JENKINS-48061] Added a test to verify we can retrieve a commit

that is not on the head of a custom ref
  • Loading branch information...
rsandell committed May 4, 2018
1 parent 36a307a commit 6ffc5710f70a58e42873d2f3d94d887b557685a9
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/test/java/jenkins/plugins/git/
@@ -528,6 +528,41 @@ public void retrieveRevision_customRef() throws Exception {
assertEquals("v3", fileAt(v3, run, source, listener));

public void retrieveRevision_customRef_descendant() throws Exception {
sampleRepo.write("file", "v1");
sampleRepo.git("commit", "--all", "--message=v1");
sampleRepo.git("tag", "v1");
sampleRepo.write("file", "v2");
sampleRepo.git("commit", "--all", "--message=v2"); // master
sampleRepo.git("checkout", "-b", "dev");
String v2 = sampleRepo.head();
sampleRepo.write("file", "v3");
sampleRepo.git("commit", "--all", "--message=v3"); // dev
String v3 = sampleRepo.head();
sampleRepo.write("file", "v4");
sampleRepo.git("commit", "--all", "--message=v4"); // dev
sampleRepo.git("update-ref", "refs/custom/foo", v3); // now this is an advertised ref so cannot be GC'd
sampleRepo.git("reset", "--hard", "HEAD~2"); // dev
String dev = sampleRepo.head();
assertNotEquals(dev, v3); //Just verifying the reset nav got correct
assertEquals(dev, v2);
sampleRepo.write("file", "v5");
sampleRepo.git("commit", "--all", "--message=v4"); // dev
// SCM.checkout does not permit a null build argument, unfortunately.
Run<?,?> run = r.buildAndAssertSuccess(r.createFreeStyleProject());
GitSCMSource source = new GitSCMSource(sampleRepo.toString());
new BranchDiscoveryTrait(),
new TagDiscoveryTrait(),
new DiscoverOtherRefsTrait("refs/custom/*")));
StreamTaskListener listener = StreamTaskListener.fromStderr();
// Test retrieval of non head revision:
assertEquals("v3", fileAt(v3, run, source, listener));

public void retrieveRevision_customRef_abbrev_sha1() throws Exception {

0 comments on commit 6ffc571

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