Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.StoredConfig


        logger.warn(MessageFormat.format("Skipping local repository {0}, busy collecting garbage", repositoryName));
        continue;
      }

      if (existingRepository != null) {
        StoredConfig config = existingRepository.getConfig();
        config.load();
        String origin = config.getString("remote", "origin", "url");
        RevCommit commit = JGitUtils.getCommit(existingRepository,
            org.eclipse.jgit.lib.Constants.FETCH_HEAD);
        if (commit != null) {
          fetchHead = commit.getName();
        }
View Full Code Here


  private void setSizeAndPosition() {
    String sz = null;
    String pos = null;
    try {
      StoredConfig config = getConfig();
      sz = config.getString("ui", null, "size");
      pos = config.getString("ui", null, "position");
    } catch (Throwable t) {
      t.printStackTrace();
    }

    // try to restore saved window size
View Full Code Here

  }

  private void saveSizeAndPosition() {
    try {
      // save window size and position
      StoredConfig config = getConfig();
      Dimension sz = GitblitManager.this.getSize();
      config.setString("ui", null, "size",
          MessageFormat.format("{0,number,0}x{1,number,0}", sz.width, sz.height));
      Point pos = GitblitManager.this.getLocationOnScreen();
      config.setString("ui", null, "position",
          MessageFormat.format("{0,number,0},{1,number,0}", pos.x, pos.y));
      config.save();
    } catch (Throwable t) {
      Utils.showException(GitblitManager.this, t);
    }
  }
View Full Code Here

    }
  }

  private void loadRegistrations() {
    try {
      StoredConfig config = getConfig();
      Set<String> servers = config.getSubsections(SERVER);
      for (String server : servers) {
        Date lastLogin = new Date(0);
        String date = config.getString(SERVER, server, "lastLogin");
        if (!StringUtils.isEmpty(date)) {
          lastLogin = dateFormat.parse(date);
        }
        String url = config.getString(SERVER, server, "url");
        String account = config.getString(SERVER, server, "account");
        char[] password;
        String pw = config.getString(SERVER, server, "password");
        if (StringUtils.isEmpty(pw)) {
          password = new char[0];
        } else {
          password = new String(Base64.decode(pw)).toCharArray();
        }
        GitblitRegistration reg = new GitblitRegistration(server, url, account, password) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void cacheFeeds() {
            writeFeedCache(this);
          }
        };
        String[] feeds = config.getStringList(SERVER, server, FEED);
        if (feeds != null) {
          // deserialize the field definitions
          for (String definition : feeds) {
            FeedModel feed = new FeedModel(definition);
            reg.feeds.add(feed);
View Full Code Here

  }

  @Override
  public boolean saveRegistration(String name, GitblitRegistration reg) {
    try {
      StoredConfig config = getConfig();
      if (!StringUtils.isEmpty(name) && !name.equals(reg.name)) {
        // delete old registration
        registrations.remove(name);
        config.unsetSection(SERVER, name);
      }

      // update registration
      config.setString(SERVER, reg.name, "url", reg.url);
      config.setString(SERVER, reg.name, "account", reg.account);
      if (reg.savePassword) {
        config.setString(SERVER, reg.name, "password",
            Base64.encodeBytes(new String(reg.password).getBytes("UTF-8")));
      } else {
        config.setString(SERVER, reg.name, "password", "");
      }
      if (reg.lastLogin != null) {
        config.setString(SERVER, reg.name, "lastLogin", dateFormat.format(reg.lastLogin));
      }
      // serialize the feed definitions
      List<String> definitions = new ArrayList<String>();
      for (FeedModel feed : reg.feeds) {
        definitions.add(feed.toString());
      }
      if (definitions.size() > 0) {
        config.setStringList(SERVER, reg.name, FEED, definitions);
      }
      config.save();
      return true;
    } catch (Throwable t) {
      Utils.showException(GitblitManager.this, t);
    }
    return false;
View Full Code Here

  @Override
  public boolean deleteRegistrations(List<GitblitRegistration> list) {
    boolean success = false;
    try {
      StoredConfig config = getConfig();
      for (GitblitRegistration reg : list) {
        config.unsetSection(SERVER, reg.name);
        registrations.remove(reg.name);
      }
      config.save();
      success = true;
    } catch (Throwable t) {
      Utils.showException(GitblitManager.this, t);
    }
    return success;
View Full Code Here

  }

  @Before
  public void initializeConfiguration() throws Exception{
    Repository r = GitBlitSuite.getHelloworldRepository();
    StoredConfig config = r.getConfig();

    config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
    config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "commitMessageRegEx", "\\d");
    config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "anotherProperty", "Hello");

    config.save();
  }
View Full Code Here

  }

  @After
  public void teardownConfiguration() throws Exception {
    Repository r = GitBlitSuite.getHelloworldRepository();
    StoredConfig config = r.getConfig();

    config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
    config.save();
  }
View Full Code Here

    }
  }

  public void testCheckoutMixedNewlines() throws Exception {
    // "git config core.autocrlf true"
    StoredConfig config = git.getRepository().getConfig();
    config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_AUTOCRLF, true);
    config.save();
    // edit <FILE1>
    File written = writeTrashFile(FILE1, "4\r\n4");
    assertEquals("4\r\n4", read(written));
    // "git add <FILE1>"
    git.add().addFilepattern(FILE1).call();
View Full Code Here

  @Test
  public void testPullLocalConflict() throws Exception {
    target.branchCreate().setName("basedOnMaster").setStartPoint(
        "refs/heads/master").setUpstreamMode(SetupUpstreamMode.NOTRACK)
        .call();
    StoredConfig config = target.getRepository().getConfig();
    config.setString("branch", "basedOnMaster", "remote", ".");
    config.setString("branch", "basedOnMaster", "merge",
        "refs/heads/master");
    config.setBoolean("branch", "basedOnMaster", "rebase", true);
    config.save();
    target.getRepository().updateRef(Constants.HEAD).link(
        "refs/heads/basedOnMaster");
    PullResult res = target.pull().call();
    // nothing to update since we don't have different data yet
    assertNull(res.getFetchResult());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.StoredConfig

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.