in javatests/com/googlesource/gerrit/plugins/supermanifest/JiriSuperManifestIT.java [266:361]
public void ImportTagWithRevisionWorks() throws Exception {
setupTestRepos("project");
// Make sure the manifest exists so the configuration loads successfully.
Project.NameKey manifest1Key = projectOperations.newProject().name(name("manifest1")).create();
TestRepository<InMemoryRepository> manifest1Repo = cloneProject(manifest1Key, admin);
Project.NameKey manifest2Key = projectOperations.newProject().name(name("manifest2")).create();
TestRepository<InMemoryRepository> manifest2Repo = cloneProject(manifest2Key, admin);
Project.NameKey superKey = projectOperations.newProject().name(name("superproject")).create();
cloneProject(superKey, admin);
pushConfig(
"[superproject \""
+ superKey.get()
+ ":refs/heads/destbranch\"]\n"
+ " srcRepo = "
+ manifest1Key.get()
+ "\n"
+ " srcRef = refs/heads/srcbranch\n"
+ " srcPath = default\n"
+ " toolType = jiri\n");
String xml2 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<manifest>\n<projects>\n"
+ "<project name=\""
+ manifest2Key.get()
+ "\" remote=\""
+ canonicalWebUrl.get()
+ manifest2Key.get()
+ "\" path=\"manifest2\" />\n"
+ "</projects>\n</manifest>\n";
Result c =
pushFactory
.create(admin.newIdent(), manifest2Repo, "Subject", "default", xml2)
.to("refs/heads/master");
c.assertOkStatus();
RevCommit commit = c.getCommit();
// Add new project, that should not be imported
xml2 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<manifest>\n<projects>\n"
+ "<project name=\""
+ manifest2Key.get()
+ "\" remote=\""
+ canonicalWebUrl.get()
+ manifest2Key.get()
+ "\" path=\"manifest2\" />\n"
+ "<project name=\""
+ testRepoKeys[1].get()
+ "\" remote=\""
+ canonicalWebUrl.get()
+ testRepoKeys[1].get()
+ "\" path=\"project2\" />\n"
+ "</projects>\n</manifest>\n";
pushFactory
.create(admin.newIdent(), manifest2Repo, "Subject", "default", xml2)
.to("refs/heads/master")
.assertOkStatus();
// XML change will trigger commit to superproject.
String xml1 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<manifest>\n<imports>\n"
+ "<import name=\""
+ manifest2Key.get()
+ "\" manifest=\"default\" remote=\""
+ canonicalWebUrl.get()
+ manifest2Key.get()
+ "\" revision=\""
+ commit.name()
+ "\"/>\n</imports>"
+ "<projects>\n"
+ "<project name=\""
+ testRepoKeys[0].get()
+ "\" remote=\""
+ canonicalWebUrl.get()
+ testRepoKeys[0].get()
+ "\" path=\"project1\" />\n"
+ "</projects>\n</manifest>\n";
pushFactory
.create(admin.newIdent(), manifest1Repo, "Subject", "default", xml1)
.to("refs/heads/srcbranch")
.assertOkStatus();
BranchApi branch = gApi.projects().name(superKey.get()).branch("refs/heads/destbranch");
assertThat(branch.file("project1").getContentType()).isEqualTo("x-git/gitlink; charset=UTF-8");
assertThat(branch.file("manifest2").getContentType()).isEqualTo("x-git/gitlink; charset=UTF-8");
assertThat(branch.file("manifest2").asString()).contains(commit.name());
assertThrows(ResourceNotFoundException.class, () -> branch.file("project2"));
}