in javatests/com/googlesource/gerrit/plugins/supermanifest/RepoSuperManifestIT.java [522:582]
public void relativeFetch() throws Exception {
// Test the setup that Android uses, where the "fetch" field is relative to the location of the
// manifest repo.
setupTestRepos("platform/project");
// The test framework adds more cruft to the prefix.
String realPrefix = testRepoKeys[0].get().split("/")[0];
Project.NameKey manifestKey =
projectOperations.newProject().name(name(realPrefix + "/manifest")).create();
TestRepository<InMemoryRepository> manifestRepo = cloneProject(manifestKey, admin);
pushConfig(
"[superproject \""
+ superKey.get()
+ ":refs/heads/destbranch\"]\n"
+ " srcRepo = "
+ manifestKey.get()
+ "\n"
+ " srcRef = refs/heads/srcbranch\n"
+ " srcPath = default.xml\n");
String url = canonicalWebUrl.get();
String remoteXml = " <remote name=\"origin\" fetch=\"..\" review=\"" + url + "\" />\n";
String defaultXml = " <default remote=\"origin\" revision=\"refs/heads/master\" />\n";
String xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<manifest>\n"
+ remoteXml
+ defaultXml
+ " <project name=\""
+ testRepoKeys[0].get()
+ "\" path=\"path1\" >\n"
+ "<copyfile src=\"file0\" dest=\"dest\" />\n"
+ "</project>"
+ "</manifest>\n";
pushFactory
.create(admin.newIdent(), manifestRepo, "Subject", "default.xml", xml)
.to("refs/heads/srcbranch")
.assertOkStatus();
BranchApi branch = gApi.projects().name(superKey.get()).branch("refs/heads/destbranch");
assertThat(branch.file("path1").getContentType()).isEqualTo("x-git/gitlink; charset=UTF-8");
assertThat(branch.file("dest").asString()).isEqualTo("file");
Config base = new Config();
String gitmodule = branch.file(".gitmodules").asString();
BlobBasedConfig cfg = new BlobBasedConfig(base, gitmodule.getBytes(UTF_8));
String subUrl = cfg.getString("submodule", testRepoKeys[0].get(), "url");
// URL is valid.
URI.create(subUrl);
// The suburls must be interpreted as relative to the parent project as a directory, i.e.
// to go from superproject/ to platform/project0, you have to do ../platform/project0
// URL is clean.
assertThat(subUrl).isEqualTo("../" + realPrefix + "/project0");
}