use of org.eclipse.jgit.storage.file.FileBasedConfig in project gitiles by GerritCodeReview.
the class GitilesConfig method loadDefault.
public static Config loadDefault(FilterConfig filterConfig) throws IOException, ConfigInvalidException {
FileBasedConfig config = new FileBasedConfig(defaultFile(filterConfig), FS.DETECTED);
config.load();
return config;
}
use of org.eclipse.jgit.storage.file.FileBasedConfig in project gerrit by GerritCodeReview.
the class SwitchSecureStore method updateGerritConfig.
private void updateGerritConfig(SitePaths sitePaths, String newSecureStore) throws IOException, ConfigInvalidException {
log.info("Set gerrit.secureStoreClass property of gerrit.config to {}", newSecureStore);
FileBasedConfig config = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
config.load();
config.setString("gerrit", null, "secureStoreClass", newSecureStore);
config.save();
}
use of org.eclipse.jgit.storage.file.FileBasedConfig in project gitblit by gitblit.
the class GitblitManager method getConfig.
private StoredConfig getConfig() throws IOException, ConfigInvalidException {
FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());
config.load();
return config;
}
use of org.eclipse.jgit.storage.file.FileBasedConfig in project gitblit by gitblit.
the class RepositoryManager method getRepositoryModel.
/**
* Returns the repository model for the specified repository. This method
* does not consider user access permissions.
*
* @param name
* @return repository model or null
*/
@Override
public RepositoryModel getRepositoryModel(String name) {
String repositoryName = fixRepositoryName(name);
String repositoryKey = getRepositoryKey(repositoryName);
if (!repositoryListCache.containsKey(repositoryKey)) {
RepositoryModel model = loadRepositoryModel(repositoryName);
if (model == null) {
return null;
}
addToCachedRepositoryList(model);
return DeepCopier.copy(model);
}
// cached model
RepositoryModel model = repositoryListCache.get(repositoryKey);
if (isCollectingGarbage(model.name)) {
// Gitblit is busy collecting garbage, use our cached model
RepositoryModel rm = DeepCopier.copy(model);
rm.isCollectingGarbage = true;
return rm;
}
// check for updates
Repository r = getRepository(model.name);
if (r == null) {
// repository is missing
removeFromCachedRepositoryList(repositoryName);
logger.error(MessageFormat.format("Repository \"{0}\" is missing! Removing from cache.", repositoryName));
return null;
}
FileBasedConfig config = (FileBasedConfig) getRepositoryConfig(r);
if (config.isOutdated()) {
// reload model
logger.debug(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
model = loadRepositoryModel(model.name);
removeFromCachedRepositoryList(model.name);
addToCachedRepositoryList(model);
} else {
// update a few repository parameters
if (!model.hasCommits) {
// update hasCommits, assume a repository only gains commits :)
model.hasCommits = JGitUtils.hasCommits(r);
}
updateLastChangeFields(r, model);
}
r.close();
// return a copy of the cached model
return DeepCopier.copy(model);
}
use of org.eclipse.jgit.storage.file.FileBasedConfig in project gitblit by gitblit.
the class ProjectManager method start.
@Override
public ProjectManager start() {
// load and cache the project metadata
projectConfigs = new FileBasedConfig(runtimeManager.getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());
getProjectConfigs();
return this;
}
Aggregations