diff options
author | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-03-25 15:30:54 -0700 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-04-23 23:03:02 -0700 |
commit | 51cccc9dae3191567a2972a7ebe692b1629808c1 (patch) | |
tree | 4df925245588b2ac0297043988103e7b7c1755dc /org.eclipse.jgit.test | |
parent | a44a687fedbf1559277b8e6706819aa9be7bce39 (diff) | |
download | jgit-51cccc9dae3191567a2972a7ebe692b1629808c1.tar.gz jgit-51cccc9dae3191567a2972a7ebe692b1629808c1.zip |
Added implementation of copyfile rule.
Change-Id: I83e8a3218be2984321342039fda507fdb1aa5f30
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 35 |
1 files changed, 35 insertions, 0 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 9fc59c578e..27d3220797 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 @@ -178,6 +178,41 @@ public class RepoCommandTest extends RepositoryTestCase { assertTrue("\"all,-a\" has have b", file.exists()); } + @Test + public void testRepoManifestCopyfile() throws Exception { + Repository localDb = 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("\">") + .append("<copyfile src=\"hello.txt\" dest=\"Hello\" />") + .append("</project>") + .append("</manifest>"); + JGitTestUtil.writeTrashFile(localDb, "manifest.xml", xmlContent.toString()); + RepoCommand command = new RepoCommand(localDb); + command.setPath(localDb.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .call(); + // The original file should exist + File hello = new File(localDb.getWorkTree(), "foo/hello.txt"); + assertTrue("The original file exists", hello.exists()); + BufferedReader reader = new BufferedReader(new FileReader(hello)); + String content = reader.readLine(); + reader.close(); + assertEquals("The original file has expected content", "world", content); + // The dest file should also exist + hello = new File(localDb.getWorkTree(), "Hello"); + assertTrue("The destination file exists", hello.exists()); + reader = new BufferedReader(new FileReader(hello)); + content = reader.readLine(); + reader.close(); + assertEquals("The destination file has expected content", "world", content); + } + private void resolveRelativeUris() { // Find the longest common prefix ends with "/" as rootUri. defaultUri = defaultDb.getDirectory().toURI().toString(); |