Example usage for org.eclipse.jgit.lib Config Config

List of usage examples for org.eclipse.jgit.lib Config Config

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Config Config.

Prototype

public Config(Config defaultConfig) 

Source Link

Document

Create an empty configuration with a fallback for missing keys.

Usage

From source file:com.google.gerrit.acceptance.ConfigAnnotationParser.java

License:Apache License

static Config parse(Config base, GerritConfigs annotation) {
    if (annotation == null) {
        return null;
    }/*from w  w w  .  j  a  va  2 s  .c  om*/

    Config cfg = new Config(base);
    for (GerritConfig c : annotation.value()) {
        parseAnnotation(cfg, c);
    }
    return cfg;
}

From source file:com.google.gerrit.acceptance.ConfigAnnotationParser.java

License:Apache License

static Config parse(Config base, GerritConfig annotation) {
    Config cfg = new Config(base);
    parseAnnotation(cfg, annotation);
    return cfg;
}

From source file:com.google.gerrit.elasticsearch.ElasticQueryAccountsTest.java

License:Apache License

@Override
protected Injector createInjector() {
    Config elasticsearchConfig = new Config(config);
    InMemoryModule.setDefaults(elasticsearchConfig);
    ElasticTestUtils.configure(elasticsearchConfig, nodeInfo.port);
    return Guice.createInjector(new InMemoryModule(elasticsearchConfig, notesMigration));
}

From source file:com.google.gerrit.server.query.account.LuceneQueryAccountsTest.java

License:Apache License

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    return Guice.createInjector(new InMemoryModule(luceneConfig, notesMigration));
}

From source file:com.google.gerrit.server.query.change.LuceneQueryChangesTest.java

License:Apache License

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    return Guice.createInjector(new InMemoryModule(luceneConfig));
}

From source file:com.google.gerrit.server.query.change.LuceneQueryChangesV14Test.java

License:Apache License

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    // Latest version with a Lucene 4 index.
    luceneConfig.setInt("index", "lucene", "testVersion", 14);
    return Guice.createInjector(new InMemoryModule(luceneConfig));
}

From source file:com.google.gerrit.server.update.RepoView.java

License:Apache License

/**
 * Get this repo's configuration./*  www.ja v  a  2 s.  co m*/
 *
 * <p>This is the storage-level config you would get with {@link Repository#getConfig()}, not, for
 * example, the Gerrit-level project config.
 *
 * @return a defensive copy of the config; modifications have no effect on the underlying config.
 */
public Config getConfig() {
    return new Config(repo.getConfig());
}

From source file:edu.tum.cs.mylyn.internal.provisioning.git.xml.GitParserHandler.java

License:Open Source License

@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (GitWriterHandler.ELEMENT_REPOSITORY.equals(qName)) {
        Config config = new Config(userConfig);
        try {//from   w  w  w  . java  2 s . c om
            repositoryConfig.append(NL);
            config.fromText(repositoryConfig.toString());
            Repository repository = createRepository(config);
            RepositoryWrapper info = new RepositoryWrapper(repository);
            repositories.add(info);
        } catch (ConfigInvalidException e) {
        }
        repositoryConfig = null;
        readRepository = false;
        readRepositoryConfig = false;
    }
}

From source file:edu.tum.cs.mylyn.provisioning.git.GitProvisioningUtil.java

License:Open Source License

public static boolean isValidGitRepository(File file) {
    File configFile = new File(file, "config");
    if (!file.exists() || !configFile.exists()) {
        return false;
    }//  w  ww  .j  av a 2 s.  c  o  m

    Config config = new Config(userConfig);
    try {
        config.fromText(FileUtils.readFileToString(configFile));
    } catch (ConfigInvalidException e) {
        return false;
    } catch (IOException e) {
        return false;
    }

    return true;
}

From source file:org.eclipse.mylyn.reviews.r4e_gerrit.internal.utils.R4EGerritServerUtility.java

License:Open Source License

/**
 * This method use the Gerrit from the git server in the workspace
 *//*from  www.ja  v  a  2s  . c  om*/
private void addWorkspaceGerritRepo() {
    RepositoryUtil repoUtil = org.eclipse.egit.core.Activator.getDefault().getRepositoryUtil();
    List<String> repoPaths = repoUtil.getConfiguredRepositories();
    RepositoryCache repositoryCache = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache();
    Repository repo = null;

    for (String repoPath : repoPaths) {
        R4EGerritPlugin.Ftracer.traceInfo("List Gerrit repository: " + repoPath);
        File gitDir = new File(repoPath);
        if (!gitDir.exists()) {
            R4EGerritPlugin.Ftracer.traceInfo("Gerrit repository do not exist: " + gitDir.getPath());
            continue;
        }
        try {
            repo = repositoryCache.lookupRepository(gitDir);
            R4EGerritPlugin.Ftracer.traceInfo("\trepository config after lookup: " + repo.getConfig());
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (repo != null) {
            Config config = new Config(repo.getConfig());
            //Look to get the remotes URL
            Set<String> remotes = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
            for (String remote : remotes) {
                String remoteURL = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote,
                        ConfigConstants.CONFIG_KEY_URL);
                R4EGerritPlugin.Ftracer.traceInfo("\t\t " + remote + " -> remoteURL: " + remoteURL);

                //Test if this is a Gerrit server and add it to the Dialogue combo
                String convertedRemoteURL = getReformatGerritServer(remoteURL);
                if (null != convertedRemoteURL) {
                    TaskRepository taskRepo = new TaskRepository(GerritConnector.CONNECTOR_KIND,
                            convertedRemoteURL);
                    taskRepo.setRepositoryLabel(convertedRemoteURL);
                    fResultTask.put(taskRepo, taskRepo.getRepositoryUrl());
                    adjustTemplatemanager(taskRepo);

                }
            }
        }
    }
}