本文整理汇总了Java中org.eclipse.jgit.transport.RemoteConfig类的典型用法代码示例。如果您正苦于以下问题:Java RemoteConfig类的具体用法?Java RemoteConfig怎么用?Java RemoteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteConfig类属于org.eclipse.jgit.transport包,在下文中一共展示了RemoteConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TransportCommand.java
示例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);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TransportCommand.java
示例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());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RemotesTest.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PullTest.java
示例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();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:FetchTest.java
示例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());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FetchTest.java
示例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;
}
开发者ID:stephenc,项目名称:asf-gitpubsub-jenkins-plugin,代码行数:18,代码来源:GitPubSubPoll.java
示例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();
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:24,代码来源:AddRemoteDialog.java
示例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}");
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:18,代码来源:GitAccessPushTest.java
示例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}"));
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:21,代码来源:GitAccessPushTest.java
示例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;
}
开发者ID:jenkinsci,项目名称:bitbucket-build-status-notifier-plugin,代码行数:17,代码来源:GitScmAdapter.java
示例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;
}
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:14,代码来源:ReplicationFileBasedConfig.java
示例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));
}
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:25,代码来源:DestinationConfiguration.java
示例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;
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JGitConnection.java
示例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;
}
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:24,代码来源:GerritUtils.java
示例16: getGerritURL
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public static String getGerritURL(Repository repository) {
String best = null;
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) {
best = "https://" + uri.getHost(); //$NON-NLS-1$
if (uri.getPort() == 29418) { //Gerrit refspec
return best;
}
break;
}
} catch (Exception e) {
GerritToolsPlugin.getDefault().log(e);
}
return best;
}
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:22,代码来源:GerritUtils.java
示例17: createBranchRemotely
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
private void createBranchRemotely(IProgressMonitor monitor,
String stableBranch, String featureBranch) throws Exception {
PushOperationSpecification spec =
BranchingUtils.setupPush(repository, stableBranch + ":" + featureBranch ); //$NON-NLS-1$
PushOperationUI op = new PushOperationUI(repository, spec, false);
op.setCredentialsProvider(new EGitCredentialsProvider());
PushOperationResult result = op.execute(monitor);
for (URIish uri: result.getURIs()) {
String msg = result.getErrorMessage(uri);
if (msg != null && !msg.isEmpty()) {
throw new CoreException(new Status(IStatus.ERROR, GerritToolsPlugin.PLUGIN_ID, msg));
}
}
FetchOperationUI fetchOp = new FetchOperationUI(repository, new RemoteConfig(repository.getConfig(), "origin"), 3000, false);
fetchOp.setCredentialsProvider(new EGitCredentialsProvider());
fetchOp.execute(monitor);
}
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:20,代码来源:CreateFeatureBranchCommand.java
示例18: execute
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
public List<RefSpec> execute() throws IOException, URISyntaxException {
final List<RefSpec> specs = new ArrayList<>();
if (refSpecs == null || refSpecs.isEmpty()) {
specs.add(new RefSpec("+refs/heads/*:refs/remotes/" + remote.getK1() + "/*"));
specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
} else {
specs.addAll(refSpecs);
}
final StoredConfig config = git.getRepository().getConfig();
final String url = config.getString("remote",
remote.getK1(),
"url");
if (url == null) {
final RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(),
remote.getK1());
remoteConfig.addURI(new URIish(remote.getK2()));
specs.forEach(remoteConfig::addFetchRefSpec);
remoteConfig.update(git.getRepository().getConfig());
git.getRepository().getConfig().save();
}
return specs;
}
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:UpdateRemoteConfig.java
示例19: prune
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
/** {@inheritDoc} */
public void prune(RemoteConfig repository) throws GitException {
try (Repository gitRepo = getRepository()) {
String remote = repository.getName();
String prefix = "refs/remotes/" + remote + "/";
Set<String> branches = listRemoteBranches(remote);
for (Ref r : new ArrayList<>(gitRepo.getAllRefs().values())) {
if (r.getName().startsWith(prefix) && !branches.contains(r.getName())) {
// delete this ref
RefUpdate update = gitRepo.updateRef(r.getName());
update.setRefLogMessage("remote branch pruned", false);
update.setForceUpdate(true);
Result res = update.delete();
}
}
} catch (URISyntaxException | IOException e) {
throw new GitException(e);
}
}
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:22,代码来源:JGitAPIImpl.java
示例20: prune
import org.eclipse.jgit.transport.RemoteConfig; //导入依赖的package包/类
/** {@inheritDoc} */
public void prune(RemoteConfig repository) throws GitException, InterruptedException {
String repoName = repository.getName();
String repoUrl = getRemoteUrl(repoName);
if (repoUrl != null && !repoUrl.isEmpty()) {
ArgumentListBuilder args = new ArgumentListBuilder();
args.add("remote", "prune", repoName);
StandardCredentials cred = credentials.get(repoUrl);
if (cred == null) cred = defaultCredentials;
try {
launchCommandWithCredentials(args, workspace, cred, new URIish(repoUrl));
} catch (URISyntaxException ex) {
throw new GitException("Invalid URL " + repoUrl, ex);
}
}
}
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:19,代码来源:CliGitAPIImpl.java
注:本文中的org.eclipse.jgit.transport.RemoteConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论