/** * {@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); } }
private void configureFetchNotes() { String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$ List<RefSpec> fetchRefSpecs = remoteConfig.getFetchRefSpecs(); for (RefSpec refSpec : fetchRefSpecs) { if(refSpec.matchSource(notesRef)) return; } remoteConfig.addFetchRefSpec(new RefSpec(notesRef + ":" + notesRef)); //$NON-NLS-1$ }
defaultRefSpec.append(config.getName()); defaultRefSpec.append(RefSpec.WILDCARD_SUFFIX); config.addFetchRefSpec(new RefSpec(defaultRefSpec.toString()));
@Override public void widgetSelected(SelectionEvent e) { SimpleFetchRefSpecWizard wiz = new SimpleFetchRefSpecWizard( repository, config); WizardDialog dlg = new WizardDialog(getShell(), wiz); if (dlg.open() == Window.OK) config.addFetchRefSpec(wiz.getSpec()); updateControls(); } });
@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; }
@Override public void widgetSelected(SelectionEvent e) { RefSpec oldSpec = (RefSpec) ((IStructuredSelection) specViewer .getSelection()).getFirstElement(); RefSpecDialog dlg = new RefSpecDialog(getShell(), repository, config, oldSpec, false); if (dlg.open() == Window.OK) { config.removeFetchRefSpec(oldSpec); config.addFetchRefSpec(dlg.getSpec()); } updateControls(); } });
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(); }
/** * Executes the {@code remote add} command with all the options and * parameters collected by the setter methods of this class. * * @return the {@link RemoteConfig} object of the added remote */ @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); } }
/** * {@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); } }
/** * Set a remote repository path. * * @param repositoryDirectory The directory in which the git repo exists. * @param remoteName The name of the remote (i.e. 'origin') * @param remoteUrl The url of the repository. */ public static void setRemote(Path repositoryDirectory, String remoteName, String remoteUrl) { Git git = null; try { git = Git.open(repositoryDirectory.toFile()); StoredConfig config = git.getRepository().getConfig(); config.unsetSection("remote", remoteName); RemoteConfig remoteConfig = new RemoteConfig(config, remoteName); remoteConfig.addURI(new URIish(remoteUrl)); remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + remoteName + "/*")); remoteConfig.update(config); config.save(); } catch (URISyntaxException | IOException e) { throw new GitException("Unable to set the remote repository", e); } finally { close(git); } }
UIText.SimpleConfigureFetchDialog_InvalidRefDialogMessage, spec.toString()))) config.addFetchRefSpec(spec);
rc.addFetchRefSpec(wcrs); rc.addFetchRefSpec(wcrs.expandFromSource(ref));
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() + "/") + "*"; //$NON-NLS-1$//$NON-NLS-2$ RefSpec refSpec = new RefSpec(); refSpec = refSpec.setForceUpdate(true); refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst); //$NON-NLS-1$ config.addFetchRefSpec(refSpec); config.update(clonedRepo.getConfig()); clonedRepo.getConfig().save(); // run the fetch command FetchCommand command = new FetchCommand(clonedRepo); command.setRemote(remote); command.setProgressMonitor(monitor); command.setTagOpt(TagOpt.FETCH_TAGS); configure(command); List<RefSpec> specs = calculateRefSpecs(dst); command.setRefSpecs(specs); return command.call(); }