diff options
author | Kaushik Lingarkar <quic_kaushikl@quicinc.com> | 2024-06-28 10:02:05 -0700 |
---|---|---|
committer | Kaushik Lingarkar <quic_kaushikl@quicinc.com> | 2024-07-02 17:16:26 +0000 |
commit | 47fd412affd8d7578606ae9b3015a911b71b13ed (patch) | |
tree | 39f5b234fc884af0dd224f02fb13fce2eaafa971 /org.eclipse.jgit.test | |
parent | e3e0a1ea35a27e50e0280715a417be7d69fa3345 (diff) | |
download | jgit-47fd412affd8d7578606ae9b3015a911b71b13ed.tar.gz jgit-47fd412affd8d7578606ae9b3015a911b71b13ed.zip |
RepoProject: read the 'dest-branch' attribute of a project
The manifest spec [1] defines a "dest-branch" attribute. Parse its
value and store it in the RepoProject. Also, create a getter/setter
for dest-branch.
[1] https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md#Element-project
Change-Id: I8ad83b0fec59d2b0967864e4de4fefde4ab971ff
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java index 76176fe347..fca27d32aa 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java @@ -177,6 +177,36 @@ public class ManifestParserTest { assertNull(bar.getUpstream()); } + @Test + public void testWithDestBranch() throws Exception { + 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=\"foo\"") + .append(" dest-branch=\"branchX\"/>") + .append("<project path=\"bar\" name=\"bar\"/>") + .append("</manifest>"); + + ManifestParser parser = new ManifestParser(null, null, "master", + "https://git.google.com/", null, null); + parser.read(new ByteArrayInputStream( + xmlContent.toString().getBytes(UTF_8))); + + Map<String, RepoProject> repos = parser.getProjects().stream().collect( + Collectors.toMap(RepoProject::getName, Function.identity())); + assertEquals(2, repos.size()); + + RepoProject foo = repos.get("foo"); + assertEquals("foo", foo.getName()); + assertEquals("branchX", foo.getDestBranch()); + + RepoProject bar = repos.get("bar"); + assertEquals("bar", bar.getName()); + assertNull(bar.getDestBranch()); + } + void testNormalize(String in, String want) { URI got = ManifestParser.normalizeEmptyPath(URI.create(in)); if (!got.toString().equals(want)) { |