本文整理汇总了Java中org.eclipse.jgit.transport.URIish类的典型用法代码示例。如果您正苦于以下问题:Java URIish类的具体用法?Java URIish怎么用?Java URIish使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URIish类属于org.eclipse.jgit.transport包,在下文中一共展示了URIish类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldShowSuccessWhenPushSucceeds
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
@Test
public void shouldShowSuccessWhenPushSucceeds() throws Exception {
XulMessageBox message = spy( new XulMessageBoxMock( XulDialogCallback.Status.ACCEPT ) );
when( document.createElement( MESSAGEBOX ) ).thenReturn( message );
doReturn( true ).when( uiGit ).hasRemote();
PushResult result = mock( PushResult.class );
doReturn( new URIish( "https://test.example.com" ) ).when( result ).getURI();
RemoteRefUpdate update = mock( RemoteRefUpdate.class );
when( update.getStatus() ).thenReturn( Status.OK );
when( result.getRemoteUpdates() ).thenReturn( Arrays.asList( update ) );
controller.push();
controller.push( IVCS.TYPE_BRANCH );
verify( uiGit ).push( "default" );
verify( uiGit ).push( IVCS.TYPE_BRANCH );
}
示例2: equals
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
/**
* Compare the two given git remote URIs. This method is a reimplementation of {@link URIish#equals(Object)} with
* one difference. The scheme of the URIs is only considered if both URIs have a non-null and non-empty scheme part.
*
* @param lhs
* the left hand side
* @param rhs
* the right hand side
* @return <code>true</code> if the two URIs are to be considered equal and <code>false</code> otherwise
*/
private static boolean equals(URIish lhs, URIish rhs) {
// We only consider the scheme if both URIs have one
if (!StringUtils.isEmptyOrNull(lhs.getScheme()) && !StringUtils.isEmptyOrNull(rhs.getScheme())) {
if (!Objects.equals(lhs.getScheme(), rhs.getScheme()))
return false;
}
if (!equals(lhs.getUser(), rhs.getUser()))
return false;
if (!equals(lhs.getPass(), rhs.getPass()))
return false;
if (!equals(lhs.getHost(), rhs.getHost()))
return false;
if (lhs.getPort() != rhs.getPort())
return false;
if (!pathEquals(lhs.getPath(), rhs.getPath()))
return false;
return true;
}
示例3: getUri
import org.eclipse.jgit.transport.URIish; //导入依赖的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);
}
}
示例4: openTransport
import org.eclipse.jgit.transport.URIish; //导入依赖的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);
}
}
示例5: testAddRemote
import org.eclipse.jgit.transport.URIish; //导入依赖的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());
}
示例6: testPushNewBranch
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPushNewBranch () 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);
// adding another branch
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/anotherBranch" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
assertEquals(2, remoteBranches.size());
assertEquals(id, remoteBranches.get("master").getId());
assertEquals(newid, remoteBranches.get("anotherBranch").getId());
assertUpdate(updates.get("anotherBranch"), "master", "anotherBranch", newid, null, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);
}
示例7: testPushDeleteBranch
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPushDeleteBranch () 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", "refs/heads/master:refs/heads/newbranch" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
Map<String, GitBranch> remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
assertEquals(2, remoteBranches.size());
assertEquals(id, remoteBranches.get("master").getId());
assertEquals(2, updates.size());
assertUpdate(updates.get("master"), "master", "master", id, null, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);
assertUpdate(updates.get("newbranch"), "master", "newbranch", id, null, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);
// deleting branch
updates = getClient(workDir).push(remoteUri, Arrays.asList(new String[] { ":refs/heads/newbranch" }), Collections.<String>emptyList(), NULL_PROGRESS_MONITOR).getRemoteRepositoryUpdates();
remoteBranches = getClient(workDir).listRemoteBranches(remoteUri, NULL_PROGRESS_MONITOR);
assertEquals(1, remoteBranches.size());
assertEquals(id, remoteBranches.get("master").getId());
assertUpdate(updates.get("newbranch"), null, "newbranch", null, id, new URIish(remoteUri).toString(), Type.BRANCH, GitRefUpdateResult.OK);
}
示例8: testPushChange
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPushChange () 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);
}
示例9: setUp
import org.eclipse.jgit.transport.URIish; //导入依赖的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();
}
示例10: testPullChangesInSameBranch
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPullChangesInSameBranch () throws Exception {
GitClient client = getClient(workDir);
client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
String commitId = makeRemoteChange("master");
GitPullResult result = client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertTrue(branches.get("master").isActive());
assertEquals(commitId, branches.get("origin/master").getId());
assertEquals(commitId, branches.get("master").getId());
Map<String, GitTransportUpdate> updates = result.getFetchResult();
assertEquals(1, updates.size());
assertUpdate(updates.get("origin/master"), "origin/master", "master", commitId, masterInfo.getRevision(), new URIish(otherWT.toURI().toURL()).toString(), Type.BRANCH, GitRefUpdateResult.FAST_FORWARD);
assertEquals(MergeStatus.FAST_FORWARD, result.getMergeResult().getMergeStatus());
assertEquals(commitId, result.getMergeResult().getNewHead());
}
示例11: testPullChangesInSameBranchPlusMerge
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPullChangesInSameBranchPlusMerge () throws Exception {
GitClient client = getClient(workDir);
client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
File f = new File(workDir, this.f.getName());
File f2 = new File(workDir, "f2");
write(f2, "hi, i am new");
add(f2);
String localCommitId = client.commit(new File[] { f2 }, "local change", null, null, NULL_PROGRESS_MONITOR).getRevision();
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
String commitId = makeRemoteChange("master");
GitPullResult result = client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertTrue(branches.get("master").isActive());
assertEquals(commitId, branches.get("origin/master").getId());
assertFalse(commitId.equals(branches.get("master").getId()));
Map<String, GitTransportUpdate> updates = result.getFetchResult();
assertEquals(1, updates.size());
assertUpdate(updates.get("origin/master"), "origin/master", "master", commitId, masterInfo.getRevision(), new URIish(otherWT.toURI().toURL()).toString(), Type.BRANCH, GitRefUpdateResult.FAST_FORWARD);
assertEquals(MergeStatus.MERGED, result.getMergeResult().getMergeStatus());
assertEquals(new HashSet<String>(Arrays.asList(commitId, localCommitId)), new HashSet<String>(Arrays.asList(result.getMergeResult().getMergedCommits())));
assertTrue(f.exists());
assertTrue(f2.exists());
}
示例12: testPullChangesMergeConflict
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPullChangesMergeConflict () throws Exception {
GitClient client = getClient(workDir);
client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
File f = new File(workDir, this.f.getName());
write(f, "hi, i am new");
add(f);
client.commit(new File[] { f }, "local change", null, null, NULL_PROGRESS_MONITOR).getRevision();
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
String commitId = makeRemoteChange("master");
GitPullResult result = client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertTrue(branches.get("master").isActive());
assertEquals(commitId, branches.get("origin/master").getId());
assertFalse(commitId.equals(branches.get("master").getId()));
Map<String, GitTransportUpdate> updates = result.getFetchResult();
assertEquals(1, updates.size());
assertUpdate(updates.get("origin/master"), "origin/master", "master", commitId, masterInfo.getRevision(), new URIish(otherWT.toURI().toURL()).toString(), Type.BRANCH, GitRefUpdateResult.FAST_FORWARD);
assertEquals(MergeStatus.CONFLICTING, result.getMergeResult().getMergeStatus());
assertEquals(new HashSet<File>(Arrays.asList(f)), new HashSet<File>(result.getMergeResult().getConflicts()));
assertEquals("<<<<<<< HEAD\nhi, i am new\n=======\nremote change\n>>>>>>> branch 'master' of " + new URIish(otherWT.toURI().toString()).toString(), read(f)); // this should be fixed in JGit
}
示例13: testPullChangesInOtherBranchPlusMerge
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPullChangesInOtherBranchPlusMerge () throws Exception {
GitClient client = getClient(workDir);
client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
File f = new File(workDir, this.f.getName());
File f2 = new File(workDir, "f2");
write(f2, "hi, i am new");
add(f2);
String localCommitId = client.commit(new File[] { f2 }, "local change", null, null, NULL_PROGRESS_MONITOR).getRevision();
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
String commitId = makeRemoteChange(BRANCH_NAME);
GitPullResult result = client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/" + BRANCH_NAME, NULL_PROGRESS_MONITOR);
branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertTrue(branches.get("master").isActive());
assertEquals(commitId, branches.get("origin/" + BRANCH_NAME).getId());
assertFalse(commitId.equals(branches.get("master").getId()));
assertFalse(localCommitId.equals(branches.get("master").getId()));
Map<String, GitTransportUpdate> updates = result.getFetchResult();
assertEquals(1, updates.size());
assertUpdate(updates.get("origin/" + BRANCH_NAME), "origin/" + BRANCH_NAME, BRANCH_NAME, commitId, branch.getId(), new URIish(otherWT.toURI().toURL()).toString(), Type.BRANCH, GitRefUpdateResult.FAST_FORWARD);
assertEquals(MergeStatus.MERGED, result.getMergeResult().getMergeStatus());
assertEquals(new HashSet<String>(Arrays.asList(commitId, localCommitId)), new HashSet<String>(Arrays.asList(result.getMergeResult().getMergedCommits())));
assertTrue(f.exists());
assertTrue(f2.exists());
}
示例14: testPullCommitMessages
import org.eclipse.jgit.transport.URIish; //导入依赖的package包/类
public void testPullCommitMessages () throws Exception {
GitClient client = getClient(workDir);
client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
File f = new File(workDir, "localFile");
makeLocalChange(f, "1");
makeRemoteChange("master");
GitPullResult result = client.pull(otherWT.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
assertEquals(GitMergeResult.MergeStatus.MERGED, result.getMergeResult().getMergeStatus());
assertEquals("Merge branch 'master' of " + new URIish(otherWT.toURI().toString()).toString(), client.log(result.getMergeResult().getNewHead(), NULL_PROGRESS_MONITOR).getFullMessage());
makeLocalChange(f, "2");
makeRemoteChange("master", "2");
result = client.pull("origin", Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*" }), "origin/master", NULL_PROGRESS_MONITOR);
assertEquals(GitMergeResult.MergeStatus.MERGED, result.getMergeResult().getMergeStatus());
assertEquals("Merge branch 'master' of " + new URIish(otherWT.toURI().toString()).toString(), client.log(result.getMergeResult().getNewHead(), NULL_PROGRESS_MONITOR).getFullMessage());
}
示例15: setUp
import org.eclipse.jgit.transport.URIish; //导入依赖的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();
}