List of usage examples for org.eclipse.jgit.api Git remoteList
public RemoteListCommand remoteList()
From source file:com.chungkwong.jgitgui.GitTreeItem.java
License:Open Source License
public GitTreeItem(Git git) { super(git);//from w w w . j a v a 2s . c om //getChildren().add(new WorkingTreeItem(directory)); //getChildren().add(new StageTreeItem(git)); try { getChildren().add(new StageTreeItem(git)); getChildren().add(new LogTreeItem(git)); getChildren().add(new NoteListTreeItem(git)); getChildren().add(new TagListTreeItem(git)); getChildren().add(new LocalTreeItem(git)); for (RemoteConfig remote : git.remoteList().call()) getChildren().add(new RemoteTreeItem(remote)); } catch (Exception ex) { Logger.getLogger(GitTreeItem.class.getName()).log(Level.SEVERE, null, ex); Util.informUser(ex); } }
From source file:org.eclipse.n4js.utils.git.GitUtils.java
License:Open Source License
/** * Returns the origin of the given repository. * * @param git// w w w .j a v a2 s. co m * the git repository * @return the origin * @throws GitAPIException * if an error occurs while accessing the given repository */ private static Optional<RemoteConfig> getOriginRemote(Git git) throws GitAPIException { List<RemoteConfig> remotes = git.remoteList().call(); if (remotes.isEmpty()) return Optional.absent(); final String origin = getDefaultRemote(); return from(remotes).firstMatch((remote) -> { return remote.getName().equals(origin); }); }
From source file:org.uberfire.java.nio.fs.jgit.JGitMirrorTest.java
License:Apache License
@Test public void testToHTTPMirrorSuccess() throws IOException, GitAPIException { final File parentFolder = createTempDirectory(); final File directory = new File(parentFolder, TARGET_GIT); new Clone(directory, ORIGIN, false, CredentialsProvider.getDefault(), null).execute(); final Git cloned = Git.open(directory); assertThat(cloned).isNotNull();/*w w w. ja v a2s .c om*/ assertThat(new ListRefs(cloned.getRepository()).execute()).is(new Condition<List<Ref>>() { @Override public boolean matches(final List<Ref> refs) { return refs.size() > 0; } }); assertThat(new ListRefs(cloned.getRepository()).execute().get(0).getName()).isEqualTo("refs/heads/master"); URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0); String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath(); assertThat(remoteUrl).isEqualTo(ORIGIN); }
From source file:org.uberfire.java.nio.fs.jgit.JGitMirrorTest.java
License:Apache License
@Test public void testEmptyCredentials() throws IOException, GitAPIException { final File parentFolder = createTempDirectory(); final File directory = new File(parentFolder, TARGET_GIT); new Clone(directory, ORIGIN, false, null, null).execute(); final Git cloned = Git.open(directory); assertThat(cloned).isNotNull();//from ww w .ja va 2s . c o m assertThat(new ListRefs(cloned.getRepository()).execute()).is(new Condition<List<Ref>>() { @Override public boolean matches(final List<Ref> refs) { return refs.size() > 0; } }); assertThat(new ListRefs(cloned.getRepository()).execute().get(0).getName()).isEqualTo("refs/heads/master"); URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0); String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath(); assertThat(remoteUrl).isEqualTo(ORIGIN); }