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)) {
private final List<CopyFile> copyfiles;
private final List<LinkFile> linkfiles;
private String upstream;
+ private String destBranch;
private String recommendShallow;
private String url;
private String defaultRevision;
return this.upstream;
}
+ /**
+ * Return the dest-branch attribute of the project
+ *
+ * @return the dest-branch value if present, null otherwise.
+ *
+ * @since 7.0
+ */
+ public String getDestBranch() {
+ return this.destBranch;
+ }
+
/**
* Set the upstream attribute of the project
*
this.upstream = upstream;
}
+ /**
+ * Set the dest-branch attribute of the project
+ *
+ * Name of a Git branch.
+ *
+ * @param destBranch
+ * value of the attribute in the manifest
+ *
+ * @since 7.0
+ */
+ public void setDestBranch(String destBranch) {
+ this.destBranch = destBranch;
+ }
+
private String getPathWithSlash() {
if (path.endsWith("/")) { //$NON-NLS-1$
return path;