use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class AllProjectsConfigTest method baseConfig.
@Test
public void baseConfig() throws Exception {
assertThat(getConfig().getString("foo", null, "bar")).isNull();
Path baseConfigPath = sitePaths.etc_dir.resolve(ALL_PROJECTS).resolve("project.config");
Files.createDirectories(baseConfigPath.getParent());
Files.write(baseConfigPath, ImmutableList.of("[foo]", "bar = base"));
assertThat(getConfig().getString("foo", null, "bar")).isEqualTo("base");
try (Repository repo = new FileRepository(allProjectsRepoFile);
TestRepository<Repository> tr = new TestRepository<>(repo)) {
tr.branch("refs/meta/config").commit().add("project.config", "[foo]\nbar = baz").create();
}
assertThat(getConfig().getString("foo", null, "bar")).isEqualTo("baz");
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class AllProjectsConfigTest method setUp.
@Before
public void setUp() throws Exception {
sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
Files.createDirectories(sitePaths.etc_dir);
Path gitPath = sitePaths.resolve("git");
StoredConfig gerritConfig = new FileBasedConfig(sitePaths.resolve("etc").resolve("gerrit.config").toFile(), FS.DETECTED);
gerritConfig.load();
gerritConfig.setString("gerrit", null, "basePath", gitPath.toAbsolutePath().toString());
gerritConfig.setString("gerrit", null, "allProjects", ALL_PROJECTS);
gerritConfig.save();
Files.createDirectories(sitePaths.resolve("git"));
allProjectsRepoFile = gitPath.resolve("All-The-Projects.git").toFile();
try (Repository repo = new FileRepository(allProjectsRepoFile)) {
repo.create(true);
}
InMemorySecureStore secureStore = new InMemorySecureStore();
InitFlags flags = new InitFlags(sitePaths, secureStore, ImmutableList.of(), false);
Section.Factory sections = (name, subsection) -> new Section(flags, sitePaths, secureStore, ui, name, subsection);
AllProjectsConfigProvider configProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
allProjectsConfig = new AllProjectsConfig(new AllProjectsNameOnInitProvider(sections), configProvider, sitePaths, flags);
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class ProjectConfigSchemaUpdateTest method noBaseConfig.
@Test
public void noBaseConfig() throws Exception {
assertThat(getConfig().getString("foo", null, "bar")).isNull();
try (Repository repo = new FileRepository(allProjectsRepoFile);
TestRepository<Repository> tr = new TestRepository<>(repo)) {
tr.branch("refs/meta/config").commit().add("project.config", "[foo]\nbar = baz").create();
}
assertThat(getConfig().getString("foo", null, "bar")).isEqualTo("baz");
}
use of org.eclipse.jgit.internal.storage.file.FileRepository in project gerrit by GerritCodeReview.
the class ProjectConfigSchemaUpdateTest method setUp.
@Before
public void setUp() throws Exception {
sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
Files.createDirectories(sitePaths.etc_dir);
Path gitPath = sitePaths.resolve("git");
StoredConfig gerritConfig = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
gerritConfig.load();
gerritConfig.setString("gerrit", null, "basePath", gitPath.toAbsolutePath().toString());
gerritConfig.setString("gerrit", null, "allProjects", ALL_PROJECTS);
gerritConfig.save();
Files.createDirectories(sitePaths.resolve("git"));
allProjectsRepoFile = gitPath.resolve("All-The-Projects.git").toFile();
try (Repository repo = new FileRepository(allProjectsRepoFile)) {
repo.create(true);
}
FileBasedAllProjectsConfigProvider configProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
factory = new ProjectConfigSchemaUpdate.Factory(new AllProjectsName(ALL_PROJECTS), configProvider);
}
Aggregations