public static ArrayMemory valueOf(RemoteConfig value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("name").assign(value.getName()); memory.refOfIndex("receivePack").assign(value.getReceivePack()); memory.refOfIndex("uploadPack").assign(value.getUploadPack()); memory.refOfIndex("mirror").assign(value.isMirror()); memory.refOfIndex("timeout").assign(value.getTimeout()); memory.refOfIndex("tagOpt").assign(value.getTagOpt().name()); ArrayMemory uris = ArrayMemory.createListed(value.getURIs().size()); for (URIish urIish : value.getURIs()) { uris.add(urIish.toPrivateString()); } memory.refOfIndex("uris").assign(uris); return memory; }
/** * Update this remote's definition within the configuration. * * @param rc * the configuration file to store ourselves into. */ public void update(Config rc) { final List<String> vlst = new ArrayList<>(); vlst.clear(); for (URIish u : getURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_URL, vlst); vlst.clear(); for (URIish u : getPushURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_PUSHURL, vlst); vlst.clear(); for (RefSpec u : getFetchRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_FETCH, vlst); vlst.clear(); for (RefSpec u : getPushRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_PUSH, vlst); set(rc, KEY_UPLOADPACK, getUploadPack(), DEFAULT_UPLOAD_PACK); set(rc, KEY_RECEIVEPACK, getReceivePack(), DEFAULT_RECEIVE_PACK); set(rc, KEY_TAGOPT, getTagOpt().option(), TagOpt.AUTO_FOLLOW.option()); set(rc, KEY_MIRROR, mirror, DEFAULT_MIRROR); set(rc, KEY_TIMEOUT, timeout, 0); }
/** * @param repository * @param uri * @param specs * @param timeout * @param dryRun */ public FetchOperationUI(Repository repository, URIish uri, List<RefSpec> specs, int timeout, boolean dryRun) { this.repository = repository; op = new FetchOperation(repository, uri, specs, timeout, dryRun); sourceString = uri.toPrivateString(); }
public String getRemoteUrl(String defaultRemoteUrl) { if (StringUtils.isBlank(defaultRemoteUrl)) { RemoteConfig remoteConfig = getJenkinsScm().getRepositories().get(0); URIish uri = remoteConfig.getURIs().get(0); return uri.toPrivateString(); } return defaultRemoteUrl; }
/** {@inheritDoc} */ @Deprecated public void clone(RemoteConfig rc, boolean useShallowClone) throws GitException, InterruptedException { // Assume only 1 URL for this repository final String source = rc.getURIs().get(0).toPrivateString(); clone(source, rc.getName(), useShallowClone, null); }
public void fetch(RemoteConfig remoteRepository) throws GitException { // Assume there is only 1 URL / refspec for simplicity fetch(remoteRepository.getURIs().get(0).toPrivateString(), remoteRepository.getFetchRefSpecs().get(0).toString()); }
/** * @param repository * @param spec * @param timeout * @param dryRun */ public PushOperationUI(Repository repository, PushOperationSpecification spec, int timeout, boolean dryRun) { this.repository = repository; this.spec = spec; this.config = null; this.remoteName = null; this.timeout = timeout; this.dryRun = dryRun; if (spec.getURIsNumber() == 1) destinationString = spec.getURIs().iterator().next() .toPrivateString(); else destinationString = NLS.bind( UIText.PushOperationUI_MultiRepositoriesDestinationString, Integer.valueOf(spec.getURIsNumber())); }
/** * Expand Parameters in the supplied remote repository with the parameter values provided in the given environment variables } * @param env Environment variables with parameter values * @param remoteRepository Remote repository with parameters * @return remote repository with expanded parameters */ public RemoteConfig getParamExpandedRepo(EnvVars env, RemoteConfig remoteRepository){ List<RefSpec> refSpecs = getRefSpecs(remoteRepository, env); return newRemoteConfig( getParameterString(remoteRepository.getName(), env), getParameterString(remoteRepository.getURIs().get(0).toPrivateString(), env), refSpecs.toArray(new RefSpec[refSpecs.size()])); }
/** {@inheritDoc} */ @Deprecated public void push(RemoteConfig repository, String refspec) throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); URIish uri = repository.getURIs().get(0); String url = uri.toPrivateString(); StandardCredentials cred = credentials.get(url); if (cred == null) cred = defaultCredentials; args.add("push", url); if (refspec != null) args.add(refspec); launchCommandWithCredentials(args, workspace, cred, uri); // Ignore output for now as there's many different formats // That are possible. }
public void push(RemoteConfig repository, String refspec) throws GitException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("push", repository.getURIs().get(0).toPrivateString()); if (refspec != null) { args.add(refspec); } launchCommand(args); // Ignore output for now as there's many different formats // That are possible. }
private void updateControls() { setErrorMessage(null); boolean anyUri = false; if (!config.getURIs().isEmpty()) { commonUriText.setText(config.getURIs().get(0).toPrivateString()); anyUri = true; } else commonUriText.setText(""); //$NON-NLS-1$ specViewer.setInput(config.getFetchRefSpecs()); specViewer.getTable().setEnabled(true); addRefSpec.setEnabled(anyUri); addRefSpecAdvanced.setEnabled(anyUri); if (config.getURIs().isEmpty()) setErrorMessage(UIText.SimpleConfigureFetchDialog_MissingUriMessage); else if (config.getFetchRefSpecs().isEmpty()) setErrorMessage(UIText.SimpleConfigureFetchDialog_MissingMappingMessage); boolean anySpec = !config.getFetchRefSpecs().isEmpty(); getButton(OK).setEnabled(anyUri && anySpec); getButton(SAVE_ONLY).setEnabled(anyUri && anySpec); }
public void createControl(Composite parent) { Composite main = new Composite(parent, SWT.NONE); main.setLayout(new GridLayout(2, false)); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); Label repositoryLabel = new Label(main, SWT.NONE); repositoryLabel.setText(UIText.FetchSourcePage_RepositoryLabel); Text repositoryText = new Text(main, SWT.READ_ONLY | SWT.BORDER); repositoryText.setText(config.getURIs().get(0).toPrivateString()); GridDataFactory.fillDefaults().grab(true, false) .applyTo(repositoryText); Label sourceLabel = new Label(main, SWT.NONE); sourceLabel.setText(UIText.FetchSourcePage_SourceLabel); sourceText = new Text(main, SWT.BORDER); sourceText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { checkPage(); } }); GridDataFactory.fillDefaults().grab(true, false).applyTo(sourceText); UIUtils.addRefContentProposalToText(sourceText, repository, new IRefListProvider() { public List<Ref> getRefList() { return getRemoteRefs(); } }); checkPage(); setControl(main); }
/** * Expand parameters in {@link #remoteRepositories} with the parameter values provided in the given build * and return them. * * @return can be empty but never null. */ public List<RemoteConfig> getParamExpandedRepos(AbstractBuild<?, ?> build) { List<RemoteConfig> expandedRepos = new ArrayList<RemoteConfig>(); for (RemoteConfig oldRepo : Util.fixNull(remoteRepositories)) { expandedRepos.add(newRemoteConfig(oldRepo.getName(), oldRepo.getURIs().get(0).toPrivateString(), new RefSpec(getRefSpec(oldRepo, build)), getRemoteConfigTargetDir(oldRepo))); } return expandedRepos; }
commonUriText.setText(config.getURIs().get(0).toPrivateString()); else commonUriText.setText(""); //$NON-NLS-1$
/** * Update this remote's definition within the configuration. * * @param rc * the configuration file to store ourselves into. */ public void update(Config rc) { final List<String> vlst = new ArrayList<>(); vlst.clear(); for (URIish u : getURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_URL, vlst); vlst.clear(); for (URIish u : getPushURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_PUSHURL, vlst); vlst.clear(); for (RefSpec u : getFetchRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_FETCH, vlst); vlst.clear(); for (RefSpec u : getPushRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_PUSH, vlst); set(rc, KEY_UPLOADPACK, getUploadPack(), DEFAULT_UPLOAD_PACK); set(rc, KEY_RECEIVEPACK, getReceivePack(), DEFAULT_RECEIVE_PACK); set(rc, KEY_TAGOPT, getTagOpt().option(), TagOpt.AUTO_FOLLOW.option()); set(rc, KEY_MIRROR, mirror, DEFAULT_MIRROR); set(rc, KEY_TIMEOUT, timeout, 0); }
CloneCommand cmd = git.clone_().url(rc.getURIs().get(0).toPrivateString()).repositoryName(rc.getName()); for (GitSCMExtension ext : extensions) { ext.decorateCloneCommand(this, build, git, listener, cmd);
/** * Update this remote's definition within the configuration. * * @param rc * the configuration file to store ourselves into. */ public void update(final Config rc) { final List<String> vlst = new ArrayList<String>(); vlst.clear(); for (final URIish u : getURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_URL, vlst); vlst.clear(); for (final URIish u : getPushURIs()) vlst.add(u.toPrivateString()); rc.setStringList(SECTION, getName(), KEY_PUSHURL, vlst); vlst.clear(); for (final RefSpec u : getFetchRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_FETCH, vlst); vlst.clear(); for (final RefSpec u : getPushRefSpecs()) vlst.add(u.toString()); rc.setStringList(SECTION, getName(), KEY_PUSH, vlst); set(rc, KEY_UPLOADPACK, getUploadPack(), DEFAULT_UPLOAD_PACK); set(rc, KEY_RECEIVEPACK, getReceivePack(), DEFAULT_RECEIVE_PACK); set(rc, KEY_TAGOPT, getTagOpt().option(), TagOpt.AUTO_FOLLOW.option()); set(rc, KEY_MIRROR, mirror, DEFAULT_MIRROR); set(rc, KEY_TIMEOUT, timeout, 0); }
@Override public void execute() throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("push", remote.toPrivateASCIIString()); if (refspec != null) { args.add(refspec); } if (force) { args.add("-f"); } if (tags) { args.add("--tags"); } if (!isAtLeastVersion(1,9,0,0) && isShallowRepository()) { throw new GitException("Can't push from shallow repository using git client older than 1.9.0"); } StandardCredentials cred = credentials.get(remote.toPrivateString()); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, remote, timeout); // Ignore output for now as there's many different formats // That are possible. } };
@Override public void widgetSelected(SelectionEvent e) { URIish uri = (URIish) ((IStructuredSelection) uriViewer .getSelection()).getFirstElement(); SelectUriWizard wiz = new SelectUriWizard(false, uri .toPrivateString()); if (new WizardDialog(getShell(), wiz).open() == Window.OK) { config.removePushURI(uri); config.addPushURI(wiz.getUri()); updateControls(); } } });
private void fetch() throws GitAPIException { for (SubtreeConfig config : subtreeConfigs) { RefSpec branchesSpec = new RefSpec( "refs/heads/*:refs/heads/original/" + config.getRemoteName() + "/*"); RefSpec tagsSpec = new RefSpec("refs/tags/*:refs/tags/original/" + config.getRemoteName() + "/*"); Git git = new Git(repository); git.fetch().setRemote(config.getFetchUri().toPrivateString()) .setRefSpecs(branchesSpec, tagsSpec).call(); } }