Skip to content
Browse files

[JENKINS-14572] Add a test case for clone option's default 'fetch tag…

…s' behaviour

Even with shallow clones "fetch all tags" is the default. Just added a
missing test case and found a true/false bug in my previous commit which
toggled the default to the not backwards compatible value.
  • Loading branch information
rhaendel committed Jun 27, 2015
1 parent bfeda3e commit 24fb7f3c441057ad09fc3ce6bbedffff797e92bc
@@ -26,7 +26,7 @@
private final Integer timeout;

public CloneOption(boolean shallow, String reference, Integer timeout) {
this(shallow, true, reference, timeout);
this(shallow, false, reference, timeout);

@@ -0,0 +1,58 @@
package hudson.plugins.git.extensions.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import hudson.model.Result;
import hudson.model.FreeStyleProject;
import hudson.plugins.git.TestGitRepo;
import hudson.plugins.git.extensions.GitSCMExtensionTest;
import hudson.plugins.git.extensions.GitSCMExtension;

import java.util.Set;

import org.jenkinsci.plugins.gitclient.Git;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.junit.Test;

* @author Ronny Händel
public class CloneOptionShallowDefaultTagsTest extends GitSCMExtensionTest {

FreeStyleProject project;
TestGitRepo repo;

public void before() throws Exception {
repo = new TestGitRepo("repo", tmp.newFolder(), listener);
project = setupBasicProject(repo);

protected GitSCMExtension getExtension() {
final boolean shallowClone = true;
final String noReference = null;
final Integer noTimeout = null;
return new CloneOption(shallowClone, noReference, noTimeout);

public void evenShallowCloningFetchesTagsByDefault() throws Exception {
final String tagName = "v0.0.1";

repo.commit("repo-init", repo.johnDoe, "repo0 initial commit");
repo.tag(tagName, "a tag that should be fetched by default");

assertTrue("scm polling should detect a change after initial commit", project.poll(listener).hasChanges());

build(project, Result.SUCCESS);

assertEquals("tag " + tagName + " should have been cloned from remote", 1, tagsInProjectWorkspaceWithName(tagName).size());

private Set<String> tagsInProjectWorkspaceWithName(String tagPattern) throws IOException, InterruptedException {
GitClient git = Git.with(listener, null).in(project.getWorkspace()).getClient();
return git.getTagNames(tagPattern);

0 comments on commit 24fb7f3

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