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


Java RemoteConfig.addFetchRefSpec方法代码示例

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


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

示例1: 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

示例2: testRemoveRemote

import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public void testRemoveRemote () throws Exception {
    File otherWT = new File(workDir.getParentFile(), "repo2");
    GitClient client = getClient(otherWT);
    client.init(NULL_PROGRESS_MONITOR);
    File f = new File(otherWT, "f");
    write(f, "init");
    client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
    client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
    
    RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
    cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
    cfg.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    cfg.update(repository.getConfig());
    repository.getConfig().save();
    
    client = getClient(workDir);
    client.fetch("origin", NULL_PROGRESS_MONITOR);
    client.createBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
    client.createBranch("nova", "origin/master", NULL_PROGRESS_MONITOR);
    
    StoredConfig config = repository.getConfig();
    assertEquals("+refs/heads/*:refs/remotes/origin/*", config.getString("remote", "origin", "fetch"));
    assertEquals("origin", config.getString("branch", "master", "remote"));
    assertEquals("refs/heads/master", config.getString("branch", "master", "merge"));
    assertEquals("origin", config.getString("branch", "nova", "remote"));
    assertEquals("refs/heads/master", config.getString("branch", "nova", "merge"));
    
    // now try to remove the remote
    client.removeRemote("origin", NULL_PROGRESS_MONITOR);
    config = repository.getConfig();
    config.load();
    // is everything deleted?
    assertEquals(0, config.getSubsections("remote").size());
    assertNull(config.getString("branch", "master", "remote"));
    assertNull(config.getString("branch", "master", "merge"));
    assertNull(config.getString("branch", "nova", "remote"));
    assertNull(config.getString("branch", "nova", "merge"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:RemotesTest.java

示例3: testGetRemotes

import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public void testGetRemotes () throws Exception {
    GitClient client = getClient(workDir);
    StoredConfig cfg = repository.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(cfg, "origin");
    
    Map<String, GitRemoteConfig> remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
    assertEquals(0, remotes.size());
    remoteConfig.update(cfg);
    cfg.save();
    
    remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
    assertEquals(0, remotes.size());
    
    remoteConfig.addURI(new URIish("file:///home/repository"));
    remoteConfig.addURI(new URIish("file:///home/repository2"));
    remoteConfig.addPushURI(new URIish("file:///home/repository"));
    remoteConfig.addPushURI(new URIish("file:///home/repository3"));
    remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/master:refs/remotes/origin/my-master"));
    remoteConfig.addPushRefSpec(new RefSpec("refs/remotes/origin/*:refs/heads/*"));
    remoteConfig.update(cfg);
    cfg.save();
    
    remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
    assertEquals(1, remotes.size());
    assertEquals("origin", remotes.get("origin").getRemoteName());
    assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository2" }), remotes.get("origin").getUris());
    assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository3" }), remotes.get("origin").getPushUris());
    assertEquals(Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*", "+refs/heads/master:refs/remotes/origin/my-master" }), remotes.get("origin").getFetchRefSpecs());
    assertEquals(Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" }), remotes.get("origin").getPushRefSpecs());
    
    GitRemoteConfig remote = client.getRemote("origin", NULL_PROGRESS_MONITOR);
    assertEquals("origin", remote.getRemoteName());
    assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository2" }), remote.getUris());
    assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository3" }), remote.getPushUris());
    assertEquals(Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*", "+refs/heads/master:refs/remotes/origin/my-master" }), remote.getFetchRefSpecs());
    assertEquals(Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" }), remote.getPushRefSpecs());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:GetRemotesTest.java

示例4: bindLocalToRemote

import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
/**
 * Binds the local repository to the remote one.
 * 
 * @param localRepository The local repository.
 * @param remoteRepo The remote repository.
 * 
 * @throws NoRepositorySelected
 * @throws URISyntaxException
 * @throws MalformedURLException
 * @throws IOException
 */
protected void bindLocalToRemote(Repository localRepository, Repository remoteRepo)
    throws NoRepositorySelected, URISyntaxException, MalformedURLException, IOException {
  
  StoredConfig config = localRepository.getConfig();
  RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
  URIish uri = new URIish(remoteRepo.getDirectory().toURI().toURL());
  remoteConfig.addURI(uri);
  RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
  remoteConfig.addFetchRefSpec(spec);
  remoteConfig.update(config);
  config.save();
  
  remoteRepos.add(remoteRepo);
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:26,代码来源:GitTestBase.java

示例5: setupRemoteSpec

import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
private void setupRemoteSpec (String remote, String fetchSpec) throws URISyntaxException, IOException {
    RemoteConfig cfg = new RemoteConfig(repository.getConfig(), remote);
    cfg.addFetchRefSpec(new RefSpec(fetchSpec));
    cfg.update(repository.getConfig());
    repository.getConfig().save();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:PullTest.java

示例6: doExecute

import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Override
protected void doExecute() {
        try {
                StoredConfig config = git.getRepository().getConfig();
                List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config);

                if (remoteConfigs.isEmpty()) {
                        URIish uri = new URIish(getUri());

                        RemoteConfig remoteConfig = new RemoteConfig(config, Constants.DEFAULT_REMOTE_NAME);
                        
                        remoteConfig.addURI(uri);
                        remoteConfig.addFetchRefSpec(new RefSpec(DEFAULT_REFSPEC_STRING));
                        remoteConfig.addPushRefSpec(new RefSpec(DEFAULT_REFSPEC_STRING));
                        remoteConfig.update(config);

                        config.save();
                }
                
                String currentBranch = git.getRepository().getBranch();
                List<RefSpec> specs = Arrays.asList(new RefSpec(currentBranch + ":" + currentBranch));

                PushCommand pushCommand = git.push().
                        setPushAll().
                        setRefSpecs(specs).
                        setDryRun(false).
                        setRemote(getUri());

                setupCredentials(pushCommand);

                if (includeTags) {
                        pushCommand.setPushTags();
                }

                if (getProgressMonitor() != null) {
                        pushCommand.setProgressMonitor(getProgressMonitor());
                }

                Iterable<PushResult> pushResults = pushCommand.setForce(true).call();

                for (PushResult pushResult : pushResults) {
                        GitTaskUtils.validateTrackingRefUpdates(PUSH_FAILED_MESSAGE, pushResult.getTrackingRefUpdates());
                        log(pushResult.getMessages());
                }
        } catch (Exception e) {
                if (pushFailedProperty != null) {
                        getProject().setProperty(pushFailedProperty, e.getMessage());
                }

                throw new GitBuildException(PUSH_FAILED_MESSAGE, e);
        }
}
 
开发者ID:rimerosolutions,项目名称:ant-git-tasks,代码行数:53,代码来源:PushTask.java


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