diff options
author | Alexander Nittka <alex@nittka.de> | 2020-03-11 11:58:03 +0100 |
---|---|---|
committer | Alexander Nittka <alex@nittka.de> | 2020-03-15 15:34:21 +0100 |
commit | 769606d0597431b96a45378ede6824729190315a (patch) | |
tree | 62f3753d9ecbc909874cc38637c3e14b914e6ed1 /org.eclipse.jgit.test/tst | |
parent | 04e16afb05912f3a163d8cda3560a5b2f1ea997f (diff) | |
download | jgit-769606d0597431b96a45378ede6824729190315a.tar.gz jgit-769606d0597431b96a45378ede6824729190315a.zip |
tag option for clone command
Allow explicitly setting the tag option for the remote configuration
when cloning a repository.
Bug: 561021
Change-Id: Iac43268a2bb231ae7599c3255bf555883d34fa32
Signed-off-by: Alexander Nittka <alex@nittka.de>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index 3d0dacab3d..b737bbec0e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -44,6 +44,7 @@ import org.eclipse.jgit.submodule.SubmoduleStatusType; import org.eclipse.jgit.submodule.SubmoduleWalk; import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.RemoteConfig; +import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.util.SystemReader; import org.junit.Test; @@ -111,6 +112,7 @@ public class CloneCommandTest extends RepositoryTestCase { .size()); assertEquals(new RefSpec("+refs/heads/*:refs/remotes/origin/*"), fetchRefSpec(git2.getRepository())); + assertTagOption(git2.getRepository(), TagOpt.AUTO_FOLLOW); } @Test @@ -801,6 +803,50 @@ public class CloneCommandTest extends RepositoryTestCase { } } + @Test + public void testCloneNoTags() throws IOException, JGitInternalException, + GitAPIException, URISyntaxException { + File directory = createTempDirectory("testCloneRepository"); + CloneCommand command = Git.cloneRepository(); + command.setDirectory(directory); + command.setURI(fileUri()); + command.setNoTags(); + Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + assertNotNull(git2); + assertNotNull(git2.getRepository().resolve("refs/heads/test")); + assertNull(git2.getRepository().resolve("tag-initial")); + assertNull(git2.getRepository().resolve("tag-for-blob")); + assertTagOption(git2.getRepository(), TagOpt.NO_TAGS); + } + + @Test + public void testCloneFollowTags() throws IOException, JGitInternalException, + GitAPIException, URISyntaxException { + File directory = createTempDirectory("testCloneRepository"); + CloneCommand command = Git.cloneRepository(); + command.setDirectory(directory); + command.setURI(fileUri()); + command.setBranch("refs/heads/master"); + command.setBranchesToClone( + Collections.singletonList("refs/heads/master")); + command.setTagOption(TagOpt.FETCH_TAGS); + Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + assertNotNull(git2); + assertNull(git2.getRepository().resolve("refs/heads/test")); + assertNotNull(git2.getRepository().resolve("tag-initial")); + assertNotNull(git2.getRepository().resolve("tag-for-blob")); + assertTagOption(git2.getRepository(), TagOpt.FETCH_TAGS); + } + + private void assertTagOption(Repository repo, TagOpt expectedTagOption) + throws URISyntaxException { + RemoteConfig remoteConfig = new RemoteConfig( + repo.getConfig(), "origin"); + assertEquals(expectedTagOption, remoteConfig.getTagOpt()); + } + private String fileUri() { return "file://" + git.getRepository().getWorkTree().getAbsolutePath(); } |