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


Java Transport.open方法代码示例

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


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

示例1: openTransport

import org.eclipse.jgit.transport.Transport; //导入方法依赖的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

示例2: testDeleteStaleReferencesFails

import org.eclipse.jgit.transport.Transport; //导入方法依赖的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

示例3: getHeadRev

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
/** {@inheritDoc} */
public Map<String, ObjectId> getHeadRev(String url) throws GitException, InterruptedException {
    Map<String, ObjectId> heads = new HashMap<>();
    try (Repository repo = openDummyRepository();
         final Transport tn = Transport.open(repo, new URIish(url))) {
        tn.setCredentialsProvider(getProvider());
        try (FetchConnection c = tn.openFetch()) {
            for (final Ref r : c.getRefs()) {
                heads.put(r.getName(), r.getPeeledObjectId() != null ? r.getPeeledObjectId() : r.getObjectId());
            }
        }
    } catch (IOException | URISyntaxException e) {
        throw new GitException(e);
    }
    return heads;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:17,代码来源:JGitAPIImpl.java

示例4: listRemoteBranches

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
private Set<String> listRemoteBranches(String remote) throws NotSupportedException, TransportException, URISyntaxException {
    Set<String> branches = new HashSet<>();
    try (final Repository repo = getRepository()) {
        StoredConfig config = repo.getConfig();
        try (final Transport tn = Transport.open(repo, new URIish(config.getString("remote",remote,"url")))) {
            tn.setCredentialsProvider(getProvider());
            try (final FetchConnection c = tn.openFetch()) {
                for (final Ref r : c.getRefs()) {
                    if (r.getName().startsWith(R_HEADS))
                        branches.add("refs/remotes/"+remote+"/"+r.getName().substring(R_HEADS.length()));
                }
            }
        }
    }
    return branches;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:17,代码来源:JGitAPIImpl.java

示例5: testFileProtocolFails

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
public void testFileProtocolFails () throws Exception {
    try {
        Transport.open(repository, new URIish(workDir.toURI().toURL()));
        fail("Workaround not needed, fix ListRemoteBranchesCommand - Transport.open(String) to Transport.open(URL)");
    } catch (NotSupportedException ex) {
        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:BranchTest.java

示例6: testFtpProtocol

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
public void testFtpProtocol () throws Exception {
    Transport t = Transport.open(repository, new URIish("ftp://ftphost/abc"));
    try {
        t.openFetch();
        fail("JGit ftp support fixed, fix #200693 workaround");
        // ftp support fixed, wa in TransportCommand.openTransport should be removed 
    } catch (ClassCastException ex) {
        // jgit has a bug that prevents from using ftp protocol
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProtocolsTestSuite.java

示例7: runImpl

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
private void runImpl() throws IOException, PermissionBackendException {
  PushResult res;
  try (Transport tn = Transport.open(git, uri)) {
    res = pushVia(tn);
  }
  updateStates(res.getRemoteUpdates());
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:8,代码来源:PushOne.java

示例8: testPushRejectNonFastForward

import org.eclipse.jgit.transport.Transport; //导入方法依赖的package包/类
public void testPushRejectNonFastForward () throws Exception {
    String remoteUri = getRemoteRepository().getWorkTree().toURI().toString();
    assertEquals(0, getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR).size());
    File f = new File(workDir, "f");
    add(f);
    String id = getClient(workDir).commit(new File[] { f }, "bbb", null, null, NULL_PROGRESS_MONITOR).getRevision();
    Map<String, GitTransportUpdate> updates = getClient(workDir).push(remoteUri, Arrays.asList(new String[] { "refs/heads/master:refs/heads/master" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
    Map<String, GitBranch> remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
    assertEquals(1, remoteBranches.size());
    assertEquals(id, remoteBranches.get("master").getId());
    assertEquals(1, updates.size());
    assertUpdate(updates.get("master"), "master", "master", id, null, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);

    // modification
    write(f, "huhu");
    add(f);
    String newid = getClient(workDir).commit(new File[] { f }, "bbb", null, null, NULL_PROGRESS_MONITOR).getRevision();
    updates = getClient(workDir).push(remoteUri, Arrays.asList(new String[] { "refs/heads/master:refs/heads/master" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
    remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
    assertEquals(1, remoteBranches.size());
    assertEquals(newid, remoteBranches.get("master").getId());
    assertEquals(1, updates.size());
    assertUpdate(updates.get("master"), "master", "master", newid, id, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);
    
    getClient(workDir).createBranch("localbranch", id, NULL_PROGRESS_MONITOR);
    getClient(workDir).checkoutRevision("localbranch", true, NULL_PROGRESS_MONITOR);
    write(f, "huhu2");
    add(f);
    id = getClient(workDir).commit(new File[] { f }, "some change before merge", null, null, NULL_PROGRESS_MONITOR).getRevision();
    updates = getClient(workDir).push(remoteUri, Arrays.asList(new String[] { "+refs/heads/localbranch:refs/heads/master" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
    remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
    assertEquals(1, remoteBranches.size());
    assertEquals(newid, remoteBranches.get("master").getId());
    assertEquals(1, updates.size());
    assertUpdate(updates.get("master"), "localbranch", "master", id, newid, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.REJECTED_NONFASTFORWARD);
    
    updates = getClient(workDir).push(remoteUri, Arrays.asList(new String[] { "refs/heads/localbranch:refs/heads/master" }), Arrays.asList(new String[] { "+refs/heads/master:refs/remotes/origin/master" }), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
    remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
    assertEquals(1, remoteBranches.size());
    assertEquals(newid, remoteBranches.get("master").getId());
    assertEquals(1, updates.size());
    assertUpdate(updates.get("master"), "localbranch", "master", id, newid, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.REJECTED_NONFASTFORWARD);
    
    // if starts failing, the WA at GitTransportUpdate.(URIish uri, TrackingRefUpdate update) should be removed
    // this.result = GitRefUpdateResult.valueOf((update.getResult() == null ? RefUpdate.Result.NOT_ATTEMPTED : update.getResult()).name());
    Transport transport = Transport.open(getRepository(getClient(workDir)), new URIish(remoteUri));
    transport.setDryRun(false);
    transport.setPushThin(true);
    PushResult pushResult = transport.push(new DelegatingProgressMonitor(NULL_PROGRESS_MONITOR),
            Transport.findRemoteRefUpdatesFor(getRepository(getClient(workDir)),
            Collections.singletonList(new RefSpec("refs/heads/localbranch:refs/heads/master")),
            Collections.singletonList(new RefSpec("refs/heads/master:refs/remotes/origin/master"))));
    assertEquals(1, pushResult.getTrackingRefUpdates().size());
    for (TrackingRefUpdate update : pushResult.getTrackingRefUpdates()) {
        // null but not NOT_ATTEMPTED, probably a bug
        // remove the WA if it starts failing here
        assertNull(update.getResult());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:60,代码来源:PushTest.java


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