本文整理汇总了Java中org.eclipse.jgit.transport.RemoteConfig类的典型用法代码示例。如果您正苦于以下问题:Java RemoteConfig类的具体用法?Java RemoteConfig怎么用?Java RemoteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteConfig类属于org.eclipse.jgit.transport包,在下文中一共展示了RemoteConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUri
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
protected final URIish getUri (boolean pushUri) throws URISyntaxException {
RemoteConfig config = getRemoteConfig();
List<URIish> uris;
if (config == null) {
uris = Collections.emptyList();
} else {
if (pushUri) {
uris = config.getPushURIs();
if (uris.isEmpty()) {
uris = config.getURIs();
}
} else {
uris = config.getURIs();
}
}
if (uris.isEmpty()) {
return new URIish(remote);
} else {
return uris.get(0);
}
}
示例2: openTransport
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
protected Transport openTransport (boolean openPush) throws URISyntaxException, NotSupportedException, TransportException {
URIish uri = getUriWithUsername(openPush);
// WA for #200693, jgit fails to initialize ftp protocol
for (TransportProtocol proto : Transport.getTransportProtocols()) {
if (proto.getSchemes().contains("ftp")) { //NOI18N
Transport.unregister(proto);
}
}
try {
Transport transport = Transport.open(getRepository(), uri);
RemoteConfig config = getRemoteConfig();
if (config != null) {
transport.applyConfig(config);
}
if (transport.getTimeout() <= 0) {
transport.setTimeout(45);
}
transport.setCredentialsProvider(getCredentialsProvider());
return transport;
} catch (IllegalArgumentException ex) {
throw new TransportException(ex.getLocalizedMessage(), ex);
}
}
示例3: testAddRemote
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public void testAddRemote () throws Exception {
StoredConfig config = repository.getConfig();
assertEquals(0, config.getSubsections("remote").size());
GitClient client = getClient(workDir);
GitRemoteConfig remoteConfig = new GitRemoteConfig("origin",
Arrays.asList(new File(workDir.getParentFile(), "repo2").toURI().toString()),
Arrays.asList(new File(workDir.getParentFile(), "repo2").toURI().toString()),
Arrays.asList("+refs/heads/*:refs/remotes/origin/*"),
Arrays.asList("refs/remotes/origin/*:+refs/heads/*"));
client.setRemote(remoteConfig, NULL_PROGRESS_MONITOR);
config.load();
RemoteConfig cfg = new RemoteConfig(config, "origin");
assertEquals(Arrays.asList(new URIish(new File(workDir.getParentFile(), "repo2").toURI().toString())), cfg.getURIs());
assertEquals(Arrays.asList(new URIish(new File(workDir.getParentFile(), "repo2").toURI().toString())), cfg.getPushURIs());
assertEquals(Arrays.asList(new RefSpec("+refs/heads/*:refs/remotes/origin/*")), cfg.getFetchRefSpecs());
assertEquals(Arrays.asList(new RefSpec("refs/remotes/origin/*:+refs/heads/*")), cfg.getPushRefSpecs());
}
示例4: setUp
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
workDir = getWorkingDirectory();
repository = getRepository(getLocalGitRepository());
otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
f = new File(otherWT, "f");
write(f, "init");
f2 = new File(otherWT, "f2");
write(f2, "init");
client.add(new File[] { f, f2 }, NULL_PROGRESS_MONITOR);
masterInfo = client.commit(new File[] { f, f2 }, "init commit", null, null, NULL_PROGRESS_MONITOR);
branch = client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
cfg.update(repository.getConfig());
repository.getConfig().save();
}
示例5: setUp
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
workDir = getWorkingDirectory();
repository = getRepository(getLocalGitRepository());
otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
f = new File(otherWT, "f");
write(f, "init");
client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
masterInfo = client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
branch = client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
cfg.update(repository.getConfig());
repository.getConfig().save();
}
示例6: testDeleteStaleReferencesFails
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public void testDeleteStaleReferencesFails () throws Exception {
setupRemoteSpec("origin", "+refs/heads/*:refs/remotes/origin/*");
GitClient client = getClient(workDir);
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertEquals(0, branches.size());
Map<String, GitTransportUpdate> updates = client.fetch("origin", NULL_PROGRESS_MONITOR);
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertEquals(2, branches.size());
new File(workDir, ".git/refs/remotes/origin").mkdirs();
write(new File(workDir, ".git/refs/remotes/origin/HEAD"), "ref: refs/remotes/origin/master");
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertEquals(2, branches.size());
// and now the master is deleted and HEAD points to nowhere :(
Transport transport = Transport.open(repository, "origin");
transport.setRemoveDeletedRefs(true);
transport.fetch(new DelegatingProgressMonitor(NULL_PROGRESS_MONITOR), new RemoteConfig(repository.getConfig(), "origin").getFetchRefSpecs());
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertEquals(1, branches.size());
}
示例7: isMatch
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
@Override
public boolean isMatch(@NonNull SCM scm) {
if (scm instanceof GitSCM && !disableNotifyScm) {
GitSCM git = (GitSCM) scm;
if (git.getExtensions().get(IgnoreNotifyCommit.class) != null) {
return false;
}
for (RemoteConfig repository : git.getRepositories()) {
for (URIish remoteUri : repository.getURIs()) {
if (GitStatus.looselyMatches(this.remoteUri, remoteUri)) {
return true;
}
}
}
}
return false;
}
示例8: doOK
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
/**
* Adds the remote as origin to the repository
*/
@Override
protected void doOK() {
super.doOK();
StoredConfig config;
try {
config = GitAccess.getInstance().getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(remoteRepoTextField.getText());
remoteConfig.addURI(uri);
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
remoteConfig.addFetchRefSpec(spec);
remoteConfig.update(config);
config.save();
} catch (NoRepositorySelected | URISyntaxException | IOException e) {
if (logger.isDebugEnabled()) {
logger.debug(e, e);
}
}
dispose();
}
示例9: testRemoteRepositoryHasNoCommitst
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
@Test(expected = MissingObjectException.class)
public void testRemoteRepositoryHasNoCommitst()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
// throws missingObjectException
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}");
}
示例10: testPushOK
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
@Test
public void testPushOK()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
gitAccess.push("", "");
assertEquals(db1.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"),
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"));
}
示例11: getCommitRepoMap
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public Map<String, URIish> getCommitRepoMap() throws Exception {
List<RemoteConfig> repoList = this.gitScm.getRepositories();
if (repoList.size() != 1) {
throw new Exception("None or multiple repos");
}
HashMap<String, URIish> commitRepoMap = new HashMap<String, URIish>();
BuildData buildData = build.getAction(BuildData.class);
if (buildData == null || buildData.getLastBuiltRevision() == null) {
logger.warning("Build data could not be found");
} else {
commitRepoMap.put(buildData.getLastBuiltRevision().getSha1String(), repoList.get(0).getURIs().get(0));
}
return commitRepoMap;
}
示例12: allRemotes
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
private static List<RemoteConfig> allRemotes(FileBasedConfig cfg) throws ConfigInvalidException {
Set<String> names = cfg.getSubsections("remote");
List<RemoteConfig> result = Lists.newArrayListWithCapacity(names.size());
for (String name : names) {
try {
result.add(new RemoteConfig(cfg, name));
} catch (URISyntaxException e) {
throw new ConfigInvalidException(
String.format("remote %s has invalid URL in %s", name, cfg.getFile()));
}
}
return result;
}
示例13: DestinationConfiguration
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
DestinationConfiguration(RemoteConfig remoteConfig, Config cfg) {
this.remoteConfig = remoteConfig;
String name = remoteConfig.getName();
urls = ImmutableList.copyOf(cfg.getStringList("remote", name, "url"));
delay = Math.max(0, getInt(remoteConfig, cfg, "replicationdelay", DEFAULT_REPLICATION_DELAY));
rescheduleDelay =
Math.max(3, getInt(remoteConfig, cfg, "rescheduledelay", DEFAULT_RESCHEDULE_DELAY));
projects = ImmutableList.copyOf(cfg.getStringList("remote", name, "projects"));
adminUrls = ImmutableList.copyOf(cfg.getStringList("remote", name, "adminUrl"));
retryDelay = Math.max(0, getInt(remoteConfig, cfg, "replicationretry", 1));
poolThreads = Math.max(0, getInt(remoteConfig, cfg, "threads", 1));
authGroupNames = ImmutableList.copyOf(cfg.getStringList("remote", name, "authGroup"));
lockErrorMaxRetries = cfg.getInt("replication", "lockErrorMaxRetries", 0);
createMissingRepos = cfg.getBoolean("remote", name, "createMissingRepositories", true);
replicatePermissions = cfg.getBoolean("remote", name, "replicatePermissions", true);
replicateProjectDeletions = cfg.getBoolean("remote", name, "replicateProjectDeletions", false);
replicateHiddenProjects = cfg.getBoolean("remote", name, "replicateHiddenProjects", false);
remoteNameStyle =
MoreObjects.firstNonNull(cfg.getString("remote", name, "remoteNameStyle"), "slash");
maxRetries =
getInt(
remoteConfig, cfg, "replicationMaxRetries", cfg.getInt("replication", "maxRetries", 0));
}
示例14: remoteList
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的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;
}
示例15: getGerritProjectName
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public static String getGerritProjectName(Repository repository) {
try {
RemoteConfig config = new RemoteConfig(repository.getConfig(),
"origin"); //$NON-NLS-1$
List<URIish> urls = new ArrayList<URIish>(config.getPushURIs());
urls.addAll(config.getURIs());
for (URIish uri: urls) {
if (uri.getPort() == 29418) { //Gerrit refspec
String path = uri.getPath();
while (path.startsWith("/")) { //$NON-NLS-1$
path = path.substring(1);
}
return path;
}
break;
}
} catch (Exception e) {
GerritToolsPlugin.getDefault().log(e);
}
return null;
}