本文整理汇总了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);
}
}
示例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;
}
示例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 "";
}
示例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) {
}
}
示例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;
}
}
}
示例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);
}
}
示例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>();
}
示例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) {
}
}
示例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 );
}
示例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;
}
示例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);
}
}