当前位置: 首页>>代码示例>>Java>>正文


Java StoredConfig.getSubsections方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.StoredConfig.getSubsections方法的典型用法代码示例。如果您正苦于以下问题:Java StoredConfig.getSubsections方法的具体用法?Java StoredConfig.getSubsections怎么用?Java StoredConfig.getSubsections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.StoredConfig的用法示例。


在下文中一共展示了StoredConfig.getSubsections方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    StoredConfig config = repository.getConfig();
    config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, remote);
    Set<String> subSections = config.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);
    for (String subSection : subSections) {
        if (remote.equals(config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_REMOTE))) {
            config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_REMOTE);
            config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_MERGE);
        }
    }
    try {
        config.save();
    } catch (IOException ex) {
        throw new GitException(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RemoveRemoteCommand.java

示例2: remoteList

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public List<Remote> remoteList(String remoteName, boolean verbose) throws GitException {
  StoredConfig config = repository.getConfig();
  Set<String> remoteNames =
      new HashSet<>(config.getSubsections(ConfigConstants.CONFIG_KEY_REMOTE));

  if (remoteName != null && remoteNames.contains(remoteName)) {
    remoteNames.clear();
    remoteNames.add(remoteName);
  }

  List<Remote> result = new ArrayList<>(remoteNames.size());
  for (String remote : remoteNames) {
    try {
      List<URIish> uris = new RemoteConfig(config, remote).getURIs();
      result.add(
          newDto(Remote.class)
              .withName(remote)
              .withUrl(uris.isEmpty() ? null : uris.get(0).toString()));
    } catch (URISyntaxException exception) {
      throw new GitException(exception.getMessage(), exception);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JGitConnection.java

示例3: getRemoteOriginURL

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public String getRemoteOriginURL() {
    try {
        StoredConfig config = getStoredConfig();
        String origin = config.getString("remote", "origin", "url");
        if (origin != null && !origin.isEmpty())
            return origin;
        Set<String> remoteNames = config.getSubsections("remote");
        if (remoteNames.size() == 0)
            return "";
        String url = config.getString("remote", remoteNames.iterator()
                .next(), "url");
        return url;
    } catch (StopTaskException e) {
    }
    return "";
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:17,代码来源:Repo.java

示例4: setRemote

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void setRemote(String remote, String url) throws IOException {
    try {
        StoredConfig config = getStoredConfig();
        Set<String> remoteNames = config.getSubsections("remote");
        if (remoteNames.contains(remote)) {
            throw new IOException(String.format(
                    "Remote %s already exists.", remote));
        }
        config.setString("remote", remote, "url", url);
        String fetch = String.format("+refs/heads/*:refs/remotes/%s/*",
                remote);
        config.setString("remote", remote, "fetch", fetch);
        config.save();
        mRemotes.add(remote);
    } catch (StopTaskException e) {
    }
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:18,代码来源:Repo.java

示例5: loadRegisteredRepositories

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
private void loadRegisteredRepositories() {
    repositoryMap = new TreeMap<String, Repository>();
    final List<String> repositoryFolders = Activator.getDefault().getRepositoryUtil().getConfiguredRepositories();

    for (final String repositoryFolder : repositoryFolders) {
        final File folder = new File(repositoryFolder);
        if (!folder.exists() || !folder.isDirectory()) {
            continue;
        }

        if (!folder.getName().equals(Constants.DOT_GIT) || !FileKey.isGitRepository(folder, FS.DETECTED)) {
            continue;
        }

        final RepositoryBuilder rb = new RepositoryBuilder().setGitDir(folder).setMustExist(true);

        try {
            final Repository repo = rb.build();
            final StoredConfig repositoryConfig = repo.getConfig();
            final Set<String> remotes = repositoryConfig.getSubsections(REMOTES_SECTION_NAME);

            for (final String remoteName : remotes) {
                final String remoteURL =
                    repositoryConfig.getString(REMOTES_SECTION_NAME, remoteName, URL_VALUE_NAME);
                repositoryMap.put(remoteURL, repo);
            }
        } catch (final Exception e) {
            log.error("Error loading local Git repository " + repositoryFolder, e); //$NON-NLS-1$
            continue;
        }
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:33,代码来源:TeamExplorerGitRepositoriesSection.java

示例6: remoteDelete

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public void remoteDelete(String name) throws GitException {
  StoredConfig config = repository.getConfig();
  Set<String> remoteNames = config.getSubsections(ConfigConstants.CONFIG_KEY_REMOTE);
  if (!remoteNames.contains(name)) {
    throw new GitException("error: Could not remove config section 'remote." + name + "'");
  }

  config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, name);
  Set<String> branches = config.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);

  for (String branch : branches) {
    String r =
        config.getString(
            ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE);
    if (name.equals(r)) {
      config.unset(
          ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE);
      config.unset(
          ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_MERGE);
      List<Branch> remoteBranches = branchList(LIST_REMOTE);
      for (Branch remoteBranch : remoteBranches) {
        if (remoteBranch.getDisplayName().startsWith(name)) {
          branchDelete(remoteBranch.getName(), true);
        }
      }
    }
  }

  try {
    config.save();
  } catch (IOException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:JGitConnection.java

示例7: getRemotes

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public Set<String> getRemotes() {
    if (mRemotes != null)
        return mRemotes;
    try {
        StoredConfig config = getStoredConfig();
        Set<String> remotes = config.getSubsections("remote");
        mRemotes = new HashSet<String>(remotes);
        return mRemotes;
    } catch (StopTaskException e) {
    }
    return new HashSet<String>();
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:13,代码来源:Repo.java

示例8: removeRemote

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void removeRemote(String remote) throws IOException {
    try {
        StoredConfig config = getStoredConfig();
        Set<String> remoteNames = config.getSubsections("remote");
        if (!remoteNames.contains(remote)) {
            throw new IOException(String.format("Remote %s does not exist.", remote));
        }
        config.unsetSection("remote", remote);
        config.save();
        mRemotes.remove(remote);
    } catch (StopTaskException e) {
    }
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:14,代码来源:Repo.java

示例9: hasRemote

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public boolean hasRemote() {
  StoredConfig config = git.getRepository().getConfig();
  Set<String> remotes = config.getSubsections( ConfigConstants.CONFIG_REMOTE_SECTION );
  return remotes.contains( Constants.DEFAULT_REMOTE_NAME );
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:7,代码来源:UIGit.java

示例10: getMappedBranches

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
private Map<String, String> getMappedBranches(
    final TfsGitRepositoryJson serverRepository,
    final Repository localRepository) {
    Map<String, String> mappedBranches = null;
    String upstreamURL = serverRepository.getRemoteUrl();
    try {
        upstreamURL = URIUtil.encodePath(serverRepository.getRemoteUrl());
    } catch (final URIException e) {
        log.error("Error encoding repository URL " + upstreamURL, e); //$NON-NLS-1$
    }

    final StoredConfig repositoryConfig = localRepository.getConfig();
    final Set<String> remotes = repositoryConfig.getSubsections(REMOTES_SECTION_NAME);

    for (final String remoteName : remotes) {
        final String remoteURL = repositoryConfig.getString(REMOTES_SECTION_NAME, remoteName, URL_VALUE_NAME);

        if (remoteURL != null && remoteURL.equalsIgnoreCase(upstreamURL)) {
            if (mappedBranches == null) {
                mappedBranches = new HashMap<String, String>();
            }

            final Set<String> branches = repositoryConfig.getSubsections(BRANCHES_SECTION_NAME);

            for (final String branch : branches) {
                final String fullBranchName = Constants.R_HEADS + branch;

                final String[] remoteNames =
                    repositoryConfig.getStringList(BRANCHES_SECTION_NAME, branch, REMOTE_VALUE_NAME);
                final String[] mappedBrancheNames =
                    repositoryConfig.getStringList(BRANCHES_SECTION_NAME, branch, MERGE_VALUE_NAME);

                for (int k = 0; k < remoteNames.length; k++) {
                    if (remoteNames[k].equals(remoteName)) {
                        final String remoteBranchName = mappedBrancheNames[k];

                        if (!mappedBranches.containsKey(remoteBranchName)) {
                            mappedBranches.put(remoteBranchName, fullBranchName);
                        }

                        break;
                    }
                }
            }

            break;
        }
    }

    return mappedBranches;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:52,代码来源:GitRepositoriesMap.java

示例11: loadRegistrations

import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
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;

				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);
				}
			}
			reg.lastLogin = lastLogin;
			loadFeedCache(reg);
			registrations.put(reg.name, reg);
		}
	} catch (Throwable t) {
		Utils.showException(GitblitManager.this, t);
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:43,代码来源:GitblitManager.java


注:本文中的org.eclipse.jgit.lib.StoredConfig.getSubsections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。