Package org.eclipse.jgit.lib

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


    private String getBranch(final Repository repository) throws IOException {
        return repository.getBranch();
    }
   
    private List<Git.Remote> getRemotes(final Repository repository) {
        Config config = repository.getConfig();
        List<Git.Remote> remotes = new ArrayList<Git.Remote>();
        for (String remote : config.getSubsections("remote")) {
            String url = config.getString("remote", remote, "url");
            remotes.add(new Git.Remote(remote, url));
        }
        return remotes;
    }
View Full Code Here


          JGitText.get().cannotPullOnARepoWithState, repo
              .getRepositoryState().name()));

    // get the configured remote for the currently checked out branch
    // stored in configuration key branch.<branch name>.remote
    Config repoConfig = repo.getConfig();
    String remote = repoConfig.getString(
        ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
        ConfigConstants.CONFIG_KEY_REMOTE);
    if (remote == null)
      // fall back to default remote
      remote = Constants.DEFAULT_REMOTE_NAME;

    // get the name of the branch in the remote repository
    // stored in configuration key branch.<branch name>.merge
    String remoteBranchName = repoConfig.getString(
        ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
        ConfigConstants.CONFIG_KEY_MERGE);
    // check if the branch is configured for pull-rebase
    boolean doRebase = repoConfig.getBoolean(
        ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
        ConfigConstants.CONFIG_KEY_REBASE, false);

    if (remoteBranchName == null) {
      String missingKey = ConfigConstants.CONFIG_BRANCH_SECTION + DOT
          + branchName + DOT + ConfigConstants.CONFIG_KEY_MERGE;
      throw new InvalidConfigurationException(MessageFormat.format(
          JGitText.get().missingConfigurationForKey, missingKey));
    }

    final boolean isRemote = !remote.equals(".");
    String remoteUri;
    FetchResult fetchRes;
    if (isRemote) {
      remoteUri = repoConfig.getString(
          ConfigConstants.CONFIG_REMOTE_SECTION, remote,
          ConfigConstants.CONFIG_KEY_URL);
      if (remoteUri == null) {
        String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + DOT
            + remote + DOT + ConfigConstants.CONFIG_KEY_URL;
View Full Code Here

    } 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

    } 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

TOP

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

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.