diff options
author | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-05-07 17:14:01 -0700 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-05-09 17:25:50 -0700 |
commit | 0b15b48f741f87277e0d1c7d29637430b880dbde (patch) | |
tree | cc955145f481da1a92b90b30664a6c06eb0724ba /org.eclipse.jgit.test/tst | |
parent | d998bc938a21cb3871b442a3bb54b5807b6e4ed2 (diff) | |
download | jgit-0b15b48f741f87277e0d1c7d29637430b880dbde.tar.gz jgit-0b15b48f741f87277e0d1c7d29637430b880dbde.zip |
Handle repo copyfile in bare repositories.
Change-Id: Ie06f0c3d1bc9b2123102efaa5542ec3c232b72cd
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 51e2b6f653..f6dea74c3e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -193,7 +193,7 @@ public class RepoCommandTest extends RepositoryTestCase { } @Test - public void testRepoManifestCopyfile() throws Exception { + public void testRepoManifestCopyFile() throws Exception { Repository localDb = createWorkRepository(); StringBuilder xmlContent = new StringBuilder(); xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") @@ -373,6 +373,44 @@ public class RepoCommandTest extends RepositoryTestCase { oldCommitId.name(), gitlink); } + @Test + public void testCopyFileBare() throws Exception { + Repository remoteDb = createBareRepository(); + Repository tempDb = createWorkRepository(); + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" />") + .append("<default revision=\"master\" remote=\"remote1\" />") + .append("<project path=\"foo\" name=\"") + .append(defaultUri) + .append("\" revision=\"") + .append(BRANCH) + .append("\" >") + .append("<copyfile src=\"hello.txt\" dest=\"Hello\" />") + .append("</project>") + .append("</manifest>"); + JGitTestUtil.writeTrashFile(tempDb, "manifest.xml", xmlContent.toString()); + RepoCommand command = new RepoCommand(remoteDb); + command.setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .call(); + // Clone it + File directory = createTempDirectory("testCopyFileBare"); + CloneCommand clone = Git.cloneRepository(); + clone.setDirectory(directory); + clone.setURI(remoteDb.getDirectory().toURI().toString()); + Repository localDb = clone.call().getRepository(); + // The Hello file should exist + File hello = new File(localDb.getWorkTree(), "Hello"); + assertTrue("The Hello file exists", hello.exists()); + // The content of Hello file should be expected + BufferedReader reader = new BufferedReader(new FileReader(hello)); + String content = reader.readLine(); + reader.close(); + assertEquals("The Hello file has expected content", "branch world", content); + } + private void resolveRelativeUris() { // Find the longest common prefix ends with "/" as rootUri. defaultUri = defaultDb.getDirectory().toURI().toString(); |