diff options
author | Yuxuan 'fishy' Wang <fishywang@google.com> | 2016-01-27 15:01:47 -0800 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@google.com> | 2016-01-27 16:01:06 -0800 |
commit | 7960fa87354aedbde0c1fedc771346286d6cac06 (patch) | |
tree | 30d818f633b43f155152828a6c4b257a8093c68e /org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo | |
parent | 114ee5a613007d21ed7a25320f8b5029c9b808bd (diff) | |
download | jgit-7960fa87354aedbde0c1fedc771346286d6cac06.tar.gz jgit-7960fa87354aedbde0c1fedc771346286d6cac06.zip |
[gitrepo] Support revision in remote tag.
Repo manifest file allows revision attribute in <remote> tag. This change
teaches JGit to read that information.
Change-Id: I1c878a2505b9d09fa09fbd404a119b71f2fb8fdb
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 53 |
1 files changed, 53 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 524d0b8e7e..164c4ba4e5 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 @@ -747,6 +747,59 @@ public class RepoCommandTest extends RepositoryTestCase { } } + @Test + public void testRemoteRevision() throws Exception { + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" />") + .append("<remote name=\"remote2\" fetch=\".\" revision=\"") + .append(BRANCH) + .append("\" />") + .append("<default remote=\"remote1\" revision=\"master\" />") + .append("<project path=\"foo\" remote=\"remote2\" name=\"") + .append(defaultUri) + .append("\" />") + .append("</manifest>"); + writeTrashFile("manifest.xml", xmlContent.toString()); + RepoCommand command = new RepoCommand(db); + command.setPath(db.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .call(); + File hello = new File(db.getWorkTree(), "foo/hello.txt"); + BufferedReader reader = new BufferedReader(new FileReader(hello)); + String content = reader.readLine(); + reader.close(); + assertEquals("submodule content should be as expected", + "branch world", content); + } + + @Test + public void testDefaultRemoteRevision() throws Exception { + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" revision=\"") + .append(BRANCH) + .append("\" />") + .append("<default remote=\"remote1\" />") + .append("<project path=\"foo\" name=\"") + .append(defaultUri) + .append("\" />") + .append("</manifest>"); + writeTrashFile("manifest.xml", xmlContent.toString()); + RepoCommand command = new RepoCommand(db); + command.setPath(db.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .call(); + File hello = new File(db.getWorkTree(), "foo/hello.txt"); + BufferedReader reader = new BufferedReader(new FileReader(hello)); + String content = reader.readLine(); + reader.close(); + assertEquals("submodule content should be as expected", + "branch world", content); + } + private void resolveRelativeUris() { // Find the longest common prefix ends with "/" as rootUri. defaultUri = defaultDb.getDirectory().toURI().toString(); |