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 69a48cc4b..024f05480 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 @@ -43,6 +43,7 @@ package org.eclipse.jgit.gitrepo; import static org.eclipse.jgit.lib.Constants.CHARSET; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -51,6 +52,8 @@ import java.io.IOException; import java.net.URI; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.Test; import org.xml.sax.SAXException; @@ -145,6 +148,29 @@ public class ManifestParserTest { } } + @Test + public void testRemoveProject() throws Exception { + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("\n") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append(""); + + ManifestParser parser = new ManifestParser(null, null, "master", + "https://git.google.com/", null, null); + parser.read(new ByteArrayInputStream( + xmlContent.toString().getBytes(CHARSET))); + + assertEquals(Stream.of("bar", "baz").collect(Collectors.toSet()), + parser.getProjects().stream().map(RepoProject::getName) + .collect(Collectors.toSet())); + } + void testNormalize(String in, String want) { URI got = ManifestParser.normalizeEmptyPath(URI.create(in)); if (!got.toString().equals(want)) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java index 929ffac11..26e783ddd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java @@ -252,6 +252,9 @@ public class ManifestParser extends DefaultHandler { RepoText.get().errorIncludeFile, path), e); } } + } else if ("remove-project".equals(qName)) { //$NON-NLS-1$ + String name = attributes.getValue("name"); //$NON-NLS-1$ + projects.removeIf((p) -> p.getName().equals(name)); } }