List of usage examples for org.eclipse.jgit.api Git lsRemoteRepository
public static LsRemoteCommand lsRemoteRepository()
From source file:bluej.groupwork.git.GitProvider.java
License:Open Source License
@Override public TeamworkCommandResult checkConnection(TeamSettings settings) { try {/* www.j a va 2 s . c o m*/ String gitUrl = makeGitUrl(settings); //perform a lsRemote on the remote git repo. LsRemoteCommand lsRemoteCommand = Git.lsRemoteRepository(); UsernamePasswordCredentialsProvider cp = new UsernamePasswordCredentialsProvider(settings.getUserName(), settings.getPassword()); // set a configuration with username and password. lsRemoteCommand.setRemote(gitUrl); //configure remote repository address. lsRemoteCommand.setCredentialsProvider(cp); //associate the repository to the username and password. lsRemoteCommand.setTags(false); //disable refs/tags in reference results lsRemoteCommand.setHeads(false); //disable refs/heads in reference results //It seems that ssh host fingerprint check is not working properly. //Disable it in a ssh connection. if (gitUrl.startsWith("ssh")) { SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host host, Session sn) { java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); sn.setConfig(config); } @Override protected JSch createDefaultJSch(FS fs) throws JSchException { return super.createDefaultJSch(fs); } }; lsRemoteCommand.setTransportConfigCallback((Transport t) -> { SshTransport sshTransport = (SshTransport) t; sshTransport.setSshSessionFactory(sshSessionFactory); }); } lsRemoteCommand.call(); //executes the lsRemote commnand. } catch (GitAPIException ex) { return new TeamworkCommandError(ex.getMessage(), ex.getLocalizedMessage()); } catch (UnsupportedSettingException ex) { return new TeamworkCommandUnsupportedSetting(ex.getMessage()); } //if we got here, it means the command was successful. return new TeamworkCommandResult(); }
From source file:com.buildautomation.jgit.api.ListRemoteRepository.java
License:Apache License
public static void listRemoteRepository() throws InvalidRemoteException, TransportException, GitAPIException { // then clone System.out.println("Listing remote repository " + REMOTE_URL); Collection<Ref> refs = Git.lsRemoteRepository().setHeads(true).setTags(true).setRemote(REMOTE_URL).call(); for (Ref ref : refs) { System.out.println("Ref: " + ref); }/*from w ww .jav a 2 s . c om*/ }
From source file:com.naveen.eclipse.gva.dataviews.taglist.TagList.java
License:Apache License
public String gettagList(String remoteURL) throws InvalidRemoteException, TransportException, GitAPIException { // then clone //System.out.println("Listing remote repository " + REMOTE_URL); remoteURL += ".git"; System.out.println("~~GVA: TagList.java Ready to call JGIT then Internet URL: " + remoteURL); String eachtag;//from w ww . j a v a2 s . c o m Collection<Ref> refs = Git.lsRemoteRepository().setHeads(true).setTags(true).setRemote(remoteURL).call(); // http://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html // Head/Tag=true - constrain to only Heads/Tags for (Ref ref : refs) { eachtag = ref.toString(); eachtag = eachtag.substring(eachtag.lastIndexOf("/") + 1, eachtag.length() - 1); tagList += eachtag + "\n"; } return tagList; }
From source file:com.oneandone.relesia.connector.scm.git.GitConnector.java
License:Apache License
@Override public Set<String> getTags() { Set<String> tags = new HashSet<String>(); authenticate();/* ww w . ja v a2 s. c o m*/ Collection<Ref> refs = null; try { refs = Git.lsRemoteRepository().setTags(true) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.user, this.password)) .setRemote(remotePath).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } // TODO: conditie if if (refs != null) { for (Ref ref : refs) { tags.add(ref.getName().split(tagsPath)[1]); } } return tags; }
From source file:com.oneandone.relesia.connector.scm.git.GitConnector.java
License:Apache License
@Override public Set<String> getBranches() { Set<String> branches = new HashSet<String>(); authenticate();//from w w w.jav a2 s . co m Collection<Ref> refs = null; try { refs = Git.lsRemoteRepository() .setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.user, this.password)) .setRemote(remotePath).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } if (refs != null) { for (Ref ref : refs) { if (ref.getName().contains(branchesPath)) { branches.add(ref.getName().split(branchesPath)[1]); } } } return branches; }
From source file:edu.nju.cs.inform.jgit.porcelain.ListRemoteRepository.java
License:Apache License
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException { // then clone System.out.println("Listing remote repository " + REMOTE_URL); Collection<Ref> refs = Git.lsRemoteRepository().setHeads(true).setTags(true).setRemote(REMOTE_URL).call(); for (Ref ref : refs) { System.out.println("Ref: " + ref); }/*from w ww . ja va 2 s . c om*/ }
From source file:facade.GitFacade.java
public static boolean validateUrl(String url) { try {/* www .j a va 2 s .c o m*/ Git.lsRemoteRepository().setHeads(true).setRemote(url).call(); } catch (Exception e) { return false; } return true; }
From source file:gitadapter.ListRemoteRepository.java
License:Apache License
public static void main(String[] args) throws GitAPIException { // then clone System.out.println("Listing remote repository " + REMOTE_URL); Collection<Ref> refs = Git.lsRemoteRepository().setHeads(true).setTags(true).setRemote(REMOTE_URL).call(); for (Ref ref : refs) { System.out.println("Ref: " + ref); }// w w w . j av a 2 s .c o m }
From source file:models.YobiUpdate.java
License:Apache License
/** * Fetch the latest version to update./* w ww .ja v a2 s. c om*/ * * @Return a string to represent the version to update; null if there is * no version to update */ public static String fetchVersionToUpdate() throws GitAPIException { Version current = Version.valueOf(Config.semverize(Config.getCurrentVersion())); Version latest = current; boolean isUpdateRequired = false; Collection<Ref> refs; refs = Git.lsRemoteRepository().setRemote(UPDATE_REPOSITORY_URL).setHeads(false).setTags(true).call(); for (Ref ref : refs) { String tag = ref.getName().replaceFirst("^refs/tags/", ""); if (tag.charAt(0) == 'v') { String versionString = Config.semverize(tag); try { Version ver = Version.valueOf(versionString); if (ver.greaterThan(latest)) { isUpdateRequired = true; latest = ver; } } catch (UnexpectedElementTypeException e) { play.Logger.warn("Failed to parse a version: " + versionString); } } } if (isUpdateRequired) { return latest.toString(); } else { return null; } }
From source file:org.exoplatform.acceptance.service.vcs.VCSRepositoryService.java
License:Open Source License
/** * <p>loadReferencesFromRemote.</p> * * @param remote a {@link org.exoplatform.acceptance.model.vcs.VCSCoordinates} object. * @return a {@link java.util.List} object. * @throws org.eclipse.jgit.api.errors.GitAPIException if any. *///from w w w.j a v a2s . com private List<VCSRef> loadReferencesFromRemote(VCSCoordinates remote) throws GitAPIException { return FluentIterable .from(Git.lsRemoteRepository().setHeads(true).setTags(true).setRemote(remote.getUrl()).call()) .transform(REF_TO_VCSREF_FUNCTION).toList(); }