Package org.eclipse.jgit.storage.file

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


  public final FileBasedConfig cfg;
  public final FileBasedConfig sec;

  @Inject
  InitFlags(final SitePaths site) throws IOException, ConfigInvalidException {
    cfg = new FileBasedConfig(site.gerrit_config, FS.DETECTED);
    sec = new FileBasedConfig(site.secure_config, FS.DETECTED);

    cfg.load();
    sec.load();
  }
View Full Code Here


      } finally {
        w.close();
      }
    }

    FileBasedConfig old =
        new FileBasedConfig(new File(p, "gerrit.config"), FS.DETECTED);

    old.setString("ldap", null, "username", "ldap.user");
    old.setString("ldap", null, "password", "ldap.s3kr3t");

    old.setString("sendemail", null, "smtpUser", "email.user");
    old.setString("sendemail", null, "smtpPass", "email.s3kr3t");
    old.save();

    final InitFlags flags = new InitFlags(site);
    final ConsoleUI ui = createStrictMock(ConsoleUI.class);
    Section.Factory sections = new Section.Factory() {
      @Override
      public Section get(String name) {
        return new Section(flags, site, ui, name);
      }
    };

    expect(ui.yesno(eq(true), eq("Upgrade '%s'"), eq(p.getCanonicalPath())))
        .andReturn(true);
    replay(ui);

    UpgradeFrom2_0_x u = new UpgradeFrom2_0_x(site, flags, ui, sections);
    assertTrue(u.isNeedUpgrade());
    u.run();
    assertFalse(u.isNeedUpgrade());
    verify(ui);

    for (String n : UpgradeFrom2_0_x.etcFiles) {
      if ("gerrit.config".equals(n)) continue;
      if ("secure.config".equals(n)) continue;
      assertEquals("# " + n + "\n",//
          new String(IO.readFully(new File(site.etc_dir, n)), "UTF-8"));
    }

    FileBasedConfig cfg = new FileBasedConfig(site.gerrit_config, FS.DETECTED);
    FileBasedConfig sec = new FileBasedConfig(site.secure_config, FS.DETECTED);
    cfg.load();
    sec.load();

    assertEquals("email.user", cfg.getString("sendemail", null, "smtpUser"));
    assertNull(cfg.getString("sendemail", null, "smtpPass"));
    assertEquals("email.s3kr3t", sec.getString("sendemail", null, "smtpPass"));

    assertEquals("ldap.user", cfg.getString("ldap", null, "username"));
    assertNull(cfg.getString("ldap", null, "password"));
    assertEquals("ldap.s3kr3t", sec.getString("ldap", null, "password"));

    u.run();
  }
View Full Code Here

    server.setUp();

    remoteRepository = src.getRepository();
    remoteURI = toURIish(app, srcName);

    FileBasedConfig cfg = remoteRepository.getConfig();
    cfg.setBoolean("http", null, "receivepack", true);
    cfg.save();
  }
View Full Code Here

    assertEquals("application/x-git-receive-pack-result", service
        .getResponseHeader(HDR_CONTENT_TYPE));
  }

  private void enableReceivePack() throws IOException {
    final FileBasedConfig cfg = remoteRepository.getConfig();
    cfg.setBoolean("http", null, "receivepack", true);
    cfg.save();
  }
View Full Code Here

    server.setUp();

    remoteRepository = src.getRepository();
    remoteURI = toURIish(app, srcName);

    FileBasedConfig cfg = remoteRepository.getConfig();
    cfg.setBoolean("http", null, "receivepack", true);
    cfg.save();
  }
View Full Code Here

      // 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(), "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

    }

    recursiveDelete(testName(), trash, true, false);

    mockSystemReader = new MockSystemReader();
    mockSystemReader.userGitConfig = new FileBasedConfig(new File(trash,
        "usergitconfig"), FS.DETECTED);
    ceilTestDirectories(getCeilings());
    SystemReader.setInstance(mockSystemReader);

    final long now = mockSystemReader.getCurrentTime();
View Full Code Here

    init(Constants.OS_USER_NAME_KEY);
    init(Constants.GIT_AUTHOR_NAME_KEY);
    init(Constants.GIT_AUTHOR_EMAIL_KEY);
    init(Constants.GIT_COMMITTER_NAME_KEY);
    init(Constants.GIT_COMMITTER_EMAIL_KEY);
    userGitConfig = new FileBasedConfig(null, null) {
      @Override
      public void load() throws IOException, ConfigInvalidException {
        // Do nothing
      }
View Full Code Here

    LockFile lf = new LockFile(file, fs);
    if (!lf.lock())
      throw new IOException(MessageFormat.format(IpLogText.get().cannotLock, file));
    try {
      FileBasedConfig cfg = new FileBasedConfig(file, fs);
      cfg.load();
      loadFrom(cfg);

      IPZillaQuery ipzilla = new IPZillaQuery(base, username, password);
      Set<CQ> current = ipzilla.getCQs(projects);

      for (CQ cq : sort(current, CQ.COMPARATOR)) {
        String id = Long.toString(cq.getID());

        set(cfg, S_CQ, id, K_DESCRIPTION, cq.getDescription());
        set(cfg, S_CQ, id, K_LICENSE, cq.getLicense());
        set(cfg, S_CQ, id, K_USE, cq.getUse());
        set(cfg, S_CQ, id, K_STATE, cq.getState());
        set(cfg, S_CQ, id, K_COMMENTS, cq.getComments());
      }

      for (CQ cq : cqs) {
        if (!current.contains(cq))
          cfg.unsetSection(S_CQ, Long.toString(cq.getID()));
      }

      lf.write(Constants.encode(cfg.toText()));
      if (!lf.commit())
        throw new IOException(MessageFormat.format(IpLogText.get().cannotWrite, file));
    } finally {
      lf.unlock();
    }
View Full Code Here

        throw die(MessageFormat.format(
            CLIText.get().configFileNotFound, //
            configFile.getAbsolutePath()));
      }

      FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED);
      cfg.load();

      WindowCacheConfig wcc = new WindowCacheConfig();
      wcc.fromConfig(cfg);
      WindowCache.reconfigure(wcc);
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.