Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.Config$Entry


    } catch (IOException e) {
      // just don't show this warning
      return;
    }
    String currentRemote = config.getName();
    Config repositoryConfig = repository.getConfig();
    Set<String> branches = repositoryConfig
        .getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);
    for (String branch : branches) {
      if (branch.equals(currentBranch))
        continue;
      String remote = repositoryConfig.getString(
          ConfigConstants.CONFIG_BRANCH_SECTION, branch,
          ConfigConstants.CONFIG_KEY_REMOTE);
      if ((remote == null && currentRemote
          .equals(Constants.DEFAULT_REMOTE_NAME))
          || (remote != null && remote.equals(currentRemote)))
View Full Code Here


    public void addValue(String newValue) {
      if (newValue.length() == 0)
        throw new IllegalArgumentException(
            UIText.ConfigurationEditorComponent_EmptyStringNotAllowed);
      Config config = getConfig();

      List<String> entries;
      if (sectionparent != null) {
        // Arrays.asList returns a fixed-size list, so we need to copy
        // over to a mutable list
        entries = new ArrayList<String>(Arrays.asList(config
            .getStringList(sectionparent.name, null, name)));
        entries.add(Math.max(index, 0), newValue);
        config.setStringList(sectionparent.name, null, name, entries);
      } else {
        // Arrays.asList returns a fixed-size list, so we need to copy
        // over to a mutable list
        entries = new ArrayList<String>(Arrays.asList(config
            .getStringList(subsectionparent.parent.name,
                subsectionparent.name, name)));
        entries.add(Math.max(index, 0), newValue);
        config.setStringList(subsectionparent.parent.name,
            subsectionparent.name, name, entries);
      }

    }
View Full Code Here

    public void changeValue(String newValue)
        throws IllegalArgumentException {
      if (newValue.length() == 0)
        throw new IllegalArgumentException(
            UIText.ConfigurationEditorComponent_EmptyStringNotAllowed);
      Config config = getConfig();

      if (index < 0) {
        if (sectionparent != null)
          config.setString(sectionparent.name, null, name, newValue);
        else
          config.setString(subsectionparent.parent.name,
              subsectionparent.name, name, newValue);
      } else {
        String[] entries;
        if (sectionparent != null) {
          entries = config.getStringList(sectionparent.name, null,
              name);
          entries[index] = newValue;
          config.setStringList(sectionparent.name, null, name,
              Arrays.asList(entries));
        } else {
          entries = config.getStringList(
              subsectionparent.parent.name,
              subsectionparent.name, name);
          entries[index] = newValue;
          config.setStringList(subsectionparent.parent.name,
              subsectionparent.name, name, Arrays.asList(entries));
        }
      }
    }
View Full Code Here

        }
      }
    }

    private Config getConfig() {
      Config config;
      if (sectionparent != null)
        config = sectionparent.parent.config;
      else
        config = subsectionparent.parent.parent.config;
      return config;
View Full Code Here

        config = subsectionparent.parent.parent.config;
      return config;
    }

    public void removeValue() {
      Config config = getConfig();

      if (index < 0) {
        if (sectionparent != null)
          config.unset(sectionparent.name, null, name);
        else
          config.unset(subsectionparent.parent.name,
              subsectionparent.name, name);
      } else {
        List<String> entries;
        if (sectionparent != null) {
          // Arrays.asList returns a fixed-size list, so we need to
          // copy over to a mutable list
          entries = new ArrayList<String>(Arrays.asList(config
              .getStringList(sectionparent.name, null, name)));

          entries.remove(index);
          config.setStringList(sectionparent.name, null, name,
              entries);
        } else {
          // Arrays.asList returns a fixed-size list, so we need to
          // copy over to a mutable list
          entries = new ArrayList<String>(Arrays.asList(config
              .getStringList(subsectionparent.parent.name,
                  subsectionparent.name, name)));
          // the list is fixed-size, so we have to copy over
          entries.remove(index);
          config.setStringList(subsectionparent.parent.name,
              subsectionparent.name, name, entries);
        }
      }
    }
View Full Code Here

  /**
   * @param repository
   * @return {@code true} if repository has been configured for Gerrit
   */
  public static boolean hasGerritConfiguration(Repository repository) {
    Config config = repository.getConfig();
    if (GerritUtil.getCreateChangeId(config))
      return true;
    try {
      List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config);
      for (RemoteConfig remoteConfig : remoteConfigs) {
View Full Code Here

public class PrintRemotes {

    public static void main(String[] args) throws IOException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        Config storedConfig = repository.getConfig();
        Set<String> remotes = storedConfig.getSubsections("remote");

        for (String remoteName : remotes) {
            String url = storedConfig.getString("remote", remoteName, "url");
            System.out.println(remoteName + " " + url);
        }

        repository.close();
    }
View Full Code Here

    return oldTreeParser;
  }

  private static DiffEntry diffFile(Repository repo, String oldCommit,
    String newCommit, String path) throws IOException, GitAPIException {
    Config config = new Config();
    config.setBoolean("diff", null, "renames", true);
    DiffConfig diffConfig = config.get(DiffConfig.KEY);
    List<DiffEntry> diffList = new Git(repo).diff().
      setOldTree(prepareTreeParser(repo, oldCommit)).
      setNewTree(prepareTreeParser(repo, newCommit)).
      setPathFilter(FollowFilter.create(path, diffConfig)).
      call();
View Full Code Here

public class ReadUserConfig {

    public static void main(String[] args) throws IOException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        Config config = repository.getConfig();
        String name = config.getString("user", null, "name");
        String email = config.getString("user", null, "email");
        if (name == null || email == null) {
            System.out.println("User identity is unknown!");
        } else {
            System.out.println("User identity is " + name + " <" + email + ">");
        }
       
        String url = config.getString("remote", "origin", "url");
        if (url != null) {
                System.out.println("Origin comes from " + url);
        }
       
        repository.close();
View Full Code Here

      FileRepositoryBuilder builder = new FileRepositoryBuilder();
      Repository repository = builder.setGitDir(new File(path)).build();
     
      RevWalk walk = new RevWalk(repository);

      Config storedConfig = repository.getConfig();
      Set<String> remotes = storedConfig.getSubsections("remote");
      
      String remoteGithub = "";
      for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        if (url.startsWith("https://github.com"))
        {
          if (!"".equals(remoteGithub))
          {
            System.out.println("Found second url - " + remoteGithub + "," + url);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.Config$Entry

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.