/** * Parse all remote blocks in an existing configuration file, looking for * remotes configuration. * * @param rc * the existing configuration to get the remote settings from. * The configuration must already be loaded into memory. * @return all remotes configurations existing in provided repository * configuration. Returned configurations are ordered * lexicographically by names. * @throws java.net.URISyntaxException * one of the URIs within the remote's configuration is invalid. */ public static List<RemoteConfig> getAllRemoteConfigs(Config rc) throws URISyntaxException { final List<String> names = new ArrayList<>(rc .getSubsections(SECTION)); Collections.sort(names); final List<RemoteConfig> result = new ArrayList<>(names .size()); for (String name : names) result.add(new RemoteConfig(rc, name)); return result; }
throws NotSupportedException, URISyntaxException, TransportException { final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote); if (doesNotExist(cfg)) { final ArrayList<Transport> transports = new ArrayList<>(1);
/** * {@inheritDoc} * <p> * Executes the {@code remote} command with all the options and parameters * collected by the setter methods of this class. */ @Override public RemoteConfig call() throws GitAPIException { checkCallable(); try { StoredConfig config = repo.getConfig(); RemoteConfig remote = new RemoteConfig(config, name); config.unsetSection(ConfigConstants.CONFIG_KEY_REMOTE, name); config.save(); return remote; } catch (IOException | URISyntaxException e) { throw new JGitInternalException(e.getMessage(), e); } }
RemoteConfig rc = new RemoteConfig(cfg, name); List<URIish> uris = rc.getPushURIs(); if (uris.isEmpty()) {
/** * Finds the tracked remote tracking branch * * @param remote * Remote name * @param mergeRef * merge Ref of the local branch tracking the remote tracking * branch * @return full remote tracking branch name or null */ private String findRemoteTrackingBranch(String remote, String mergeRef) { RemoteConfig remoteConfig; try { remoteConfig = new RemoteConfig(config, remote); } catch (URISyntaxException e) { return null; } for (RefSpec refSpec : remoteConfig.getFetchRefSpecs()) { if (refSpec.matchSource(mergeRef)) { RefSpec expanded = refSpec.expandFromSource(mergeRef); return expanded.getDestination(); } } return null; }
RemoteConfig remote = new RemoteConfig(config, name); if (push) { List<URIish> uris = remote.getPushURIs();
/** * @return remote config * @throws URISyntaxException on incorrect URI syntax */ public RemoteConfig toRemote() throws URISyntaxException { return new RemoteConfig(this, name); } }
/** * @return RemoteConfig * @throws java.net.URISyntaxException if any. */ public org.eclipse.jgit.transport.RemoteConfig toRemote() throws URISyntaxException { return new org.eclipse.jgit.transport.RemoteConfig(this, name); } }
/** * {@inheritDoc} * <p> * Executes the {@code remote add} command with all the options and * parameters collected by the setter methods of this class. */ @Override public RemoteConfig call() throws GitAPIException { checkCallable(); try { StoredConfig config = repo.getConfig(); RemoteConfig remote = new RemoteConfig(config, name); RefSpec refSpec = new RefSpec(); refSpec = refSpec.setForceUpdate(true); refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$ Constants.R_REMOTES + name + "/*"); //$NON-NLS-1$ remote.addFetchRefSpec(refSpec); remote.addURI(uri); remote.update(config); config.save(); return remote; } catch (IOException | URISyntaxException e) { throw new JGitInternalException(e.getMessage(), e); } }
URISyntaxException, TransportException { if (local != null) { final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote); if (doesNotExist(cfg)) return open(local, new URIish(remote), null);
RemoteConfig config = new RemoteConfig(repo.getConfig(), getRemote()); refSpecs.addAll(config.getPushRefSpecs());
private FetchResult fetch(Repository clonedRepo, URIish u) throws URISyntaxException, org.eclipse.jgit.api.errors.TransportException, IOException, GitAPIException { // create the remote config and save it RemoteConfig config = new RemoteConfig(clonedRepo.getConfig(), remote); config.addURI(u); final String dst = (bare ? Constants.R_HEADS : Constants.R_REMOTES + config.getName() + '/') + '*'; boolean fetchAll = cloneAllBranches || branchesToClone == null || branchesToClone.isEmpty(); config.setFetchRefSpecs(calculateRefSpecs(fetchAll, dst)); config.update(clonedRepo.getConfig()); clonedRepo.getConfig().save(); // run the fetch command FetchCommand command = new FetchCommand(clonedRepo); command.setRemote(remote); command.setProgressMonitor(monitor); command.setTagOpt(fetchAll ? TagOpt.FETCH_TAGS : TagOpt.AUTO_FOLLOW); configure(command); return command.call(); }
remoteConfig = new RemoteConfig(getConfig(), "origin"); //$NON-NLS-1$ } catch (URISyntaxException e) {
/** * Does the given remote exist in the repository? * * @param repository * @param remote * @return true if exists, false otherwise * @throws URISyntaxException */ protected static boolean hasRemote(final Repository repository, final String remote) throws URISyntaxException { final RemoteConfig config = new RemoteConfig(repository.getConfig(), remote); return !config.getURIs().isEmpty() || !config.getPushURIs().isEmpty(); }
/** * @param shell * @param repository * @param remoteName * the remote name to use * @return the dialog to open, or null */ public static Dialog getDialog(Shell shell, Repository repository, String remoteName) { RemoteConfig configToUse; try { configToUse = new RemoteConfig(repository.getConfig(), remoteName); } catch (URISyntaxException e) { Activator.handleError(e.getMessage(), e, true); return null; } return new SimpleConfigureFetchDialog(shell, repository, configToUse, false); }
/** * @param shell * @param repository * @param remoteName * the remote to use * @return the dialog to open, or null */ public static Dialog getDialog(Shell shell, Repository repository, String remoteName) { RemoteConfig configToUse; try { configToUse = new RemoteConfig(repository.getConfig(), remoteName); } catch (URISyntaxException e) { Activator.handleError(e.getMessage(), e, true); return null; } return new SimpleConfigurePushDialog(shell, repository, configToUse, false); }
/** * {@inheritDoc} * <p> * Executes the {@code remote} command with all the options and parameters * collected by the setter methods of this class. */ @Override public RemoteConfig call() throws GitAPIException { checkCallable(); try { StoredConfig config = repo.getConfig(); RemoteConfig remote = new RemoteConfig(config, name); config.unsetSection(ConfigConstants.CONFIG_KEY_REMOTE, name); config.save(); return remote; } catch (IOException | URISyntaxException e) { throw new JGitInternalException(e.getMessage(), e); } }
@Nonnull private RemoteConfig getRemoteConfig(final URIish uri, final StoredConfig config) throws URISyntaxException, IOException { RemoteConfig remote = new RemoteConfig(config, "origin"); remote.addFetchRefSpec(new RefSpec().setForceUpdate(true).setSourceDestination("refs/heads/*", "refs/remotes/origin/*")); remote.addURI(uri); remote.update(config); config.save(); return remote; }
/** * Executes the {@code remote} command with all the options and parameters * collected by the setter methods of this class. * * @return the {@link RemoteConfig} object of the removed remote */ @Override public RemoteConfig call() throws GitAPIException { checkCallable(); try { StoredConfig config = repo.getConfig(); RemoteConfig remote = new RemoteConfig(config, name); config.unsetSection(ConfigConstants.CONFIG_KEY_REMOTE, name); config.save(); return remote; } catch (IOException | URISyntaxException e) { throw new JGitInternalException(e.getMessage(), e); } }
private void saveRemote(final URIish uri) throws URISyntaxException, IOException { final StoredConfig dstcfg = dst.getConfig(); final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName); rc.addURI(uri); rc.addFetchRefSpec(new RefSpec().setForceUpdate(true) .setSourceDestination(Constants.R_HEADS + "*", //$NON-NLS-1$ Constants.R_REMOTES + remoteName + "/*")); //$NON-NLS-1$ rc.update(dstcfg); dstcfg.save(); }