Search in sources :

Example 11 with FileBasedConfig

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;
}
Also used : FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig)

Example 12 with FileBasedConfig

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();
}
Also used : FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig)

Example 13 with FileBasedConfig

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;
}
Also used : FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig)

Example 14 with FileBasedConfig

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);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) RepositoryModel(com.gitblit.models.RepositoryModel) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig)

Example 15 with FileBasedConfig

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;
}
Also used : FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig)

Aggregations

FileBasedConfig (org.eclipse.jgit.storage.file.FileBasedConfig)23 IOException (java.io.IOException)12 File (java.io.File)10 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)8 UserModel (com.gitblit.models.UserModel)4 HashMap (java.util.HashMap)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 RefModel (com.gitblit.models.RefModel)2 TeamModel (com.gitblit.models.TeamModel)2 X509Metadata (com.gitblit.utils.X509Utils.X509Metadata)2 Date (java.util.Date)2 List (java.util.List)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 Config (org.eclipse.jgit.lib.Config)2