Package org.eclipse.jgit.storage.file

Examples of org.eclipse.jgit.storage.file.FileBasedConfig


      // We only want the repository's configuration file, and not
      // the user file, as these parameters must be unique to this
      // repository and not inherited from other files.
      //
      File path = safeFS().resolve(getGitDir(), Constants.CONFIG);
      FileBasedConfig cfg = new FileBasedConfig(path, safeFS());
      try {
        cfg.load();
      } catch (ConfigInvalidException err) {
        throw new IllegalArgumentException(MessageFormat.format(
            JGitText.get().repositoryConfigFileInvalid, path
                .getAbsolutePath(), err.getMessage()));
      }
View Full Code Here


    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }

    // Save path and URL to parent repository's .gitmodules file
    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        repo.getWorkTree(), Constants.DOT_GIT_MODULES), repo.getFS());
    try {
      modulesConfig.load();
      modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
          path, ConfigConstants.CONFIG_KEY_PATH, path);
      modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
          path, ConfigConstants.CONFIG_KEY_URL, uri);
      modulesConfig.save();
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
View Full Code Here

   */
  public SubmoduleWalk loadModulesConfig() throws IOException, ConfigInvalidException {
    if (rootTree == null) {
      File modulesFile = new File(repository.getWorkTree(),
          Constants.DOT_GIT_MODULES);
      FileBasedConfig config = new FileBasedConfig(modulesFile,
          repository.getFS());
      config.load();
      modulesConfig = config;
    } else {
      TreeWalk configWalk = new TreeWalk(repository);
      try {
        configWalk.addTree(rootTree);
View Full Code Here

    super(options);

    systemConfig = SystemReader.getInstance().openSystemConfig(null, getFS());
    userConfig = SystemReader.getInstance().openUserConfig(systemConfig,
        getFS());
    repoConfig = new FileBasedConfig(userConfig, getFS().resolve(
        getDirectory(), Constants.CONFIG),
        getFS());

    loadSystemConfig();
    loadUserConfig();
View Full Code Here

   *
   * @throws IOException
   *             in case of IO problem
   */
  public void create(boolean bare) throws IOException {
    final FileBasedConfig cfg = getConfig();
    if (cfg.getFile().exists()) {
      throw new IllegalStateException(MessageFormat.format(
          JGitText.get().repositoryAlreadyExists, getDirectory()));
    }
    FileUtils.mkdirs(getDirectory(), true);
    refs.create();
    objectDatabase.create();

    FileUtils.mkdir(new File(getDirectory(), "branches")); //$NON-NLS-1$
    FileUtils.mkdir(new File(getDirectory(), "hooks")); //$NON-NLS-1$

    RefUpdate head = updateRef(Constants.HEAD);
    head.disableRefLog();
    head.link(Constants.R_HEADS + Constants.MASTER);

    final boolean fileMode;
    if (getFS().supportsExecute()) {
      File tmp = File.createTempFile("try", "execute", getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$

      getFS().setExecute(tmp, true);
      final boolean on = getFS().canExecute(tmp);

      getFS().setExecute(tmp, false);
      final boolean off = getFS().canExecute(tmp);
      FileUtils.delete(tmp);

      fileMode = on && !off;
    } else {
      fileMode = false;
    }

    cfg.setInt(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, 0);
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_FILEMODE, fileMode);
    if (bare)
      cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
          ConfigConstants.CONFIG_KEY_BARE, true);
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, !bare);
    if (SystemReader.getInstance().isMacOS())
      // Java has no other way
      cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
          ConfigConstants.CONFIG_KEY_PRECOMPOSEUNICODE, true);
    cfg.save();
  }
View Full Code Here

    this.site = site;
  }

  @Override
  public Config get() {
    FileBasedConfig cfg = new FileBasedConfig(site.gerrit_config, FS.DETECTED);

    if (!cfg.getFile().exists()) {
      log.info("No " + site.gerrit_config.getAbsolutePath()
          + "; assuming defaults");
      return cfg;
    }

    try {
      cfg.load();
    } catch (IOException e) {
      throw new ProvisionException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
      throw new ProvisionException(e.getMessage(), e);
    }

    if (site.secure_config.exists()) {
      cfg = new FileBasedConfig(cfg, site.secure_config, FS.DETECTED);
      try {
        cfg.load();
      } catch (IOException e) {
        throw new ProvisionException(e.getMessage(), e);
      } catch (ConfigInvalidException e) {
        throw new ProvisionException(e.getMessage(), e);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.storage.file.FileBasedConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.