/** * 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); }
private String joinRefSpecs(List<RefSpec> refSpecs) { if (refSpecs.isEmpty()) { return ""; } if (refSpecs.size() == 1) { return refSpecs.get(0).toString(); } StringBuilder result = new StringBuilder(refSpecs.size() * 50 /*most ref specs are ~50 chars*/); boolean first = true; for (RefSpec r : refSpecs) { if (first) { first = false; } else { result.append(' '); } result.append(r.toString()); } return result.toString(); }
public void modifyText(ModifyEvent e) { if (!specString.isFocusControl() || getSpec().toString().equals(specString.getText())) return; setSpec(new RefSpec(specString.getText())); } });
private List<RefSpec> getRefSpecs(RemoteConfig repo, EnvVars env) { List<RefSpec> refSpecs = new ArrayList<>(); for (RefSpec refSpec : repo.getFetchRefSpecs()) { refSpecs.add(new RefSpec(getParameterString(refSpec.toString(), env))); } return refSpecs; }
private String getRefSpec(RemoteConfig repo, AbstractBuild<?, ?> build) { String refSpec = repo.getFetchRefSpecs().get(0).toString(); ParametersAction parameters = build.getAction(ParametersAction.class); if (parameters != null) { refSpec = parameters.substitute(build, refSpec); } return refSpec; }
private void setSpec(RefSpec spec) { setErrorMessage(null); this.spec = spec; String newSourceText = spec.getSource() != null ? spec.getSource() : ""; //$NON-NLS-1$ String newDestinationText = spec.getDestination() != null ? spec .getDestination() : ""; //$NON-NLS-1$ String newStringText = spec.toString(); if (!sourceText.getText().equals(newSourceText)) sourceText.setText(newSourceText); if (!destinationText.getText().equals(newDestinationText)) destinationText.setText(newDestinationText); if (!specString.getText().equals(newStringText)) specString.setText(newStringText); forceButton.setSelection(spec.isForceUpdate()); if (sourceText.getText().length() == 0 || destinationText.getText().length() == 0) setErrorMessage(UIText.RefSpecDialog_MissingDataMessage); getButton(OK).setEnabled( sourceText.getText().length() > 0 && destinationText.getText().length() > 0); }
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()); }
private RemoteConfig newRemoteConfig(String name, String refUrl, RefSpec... refSpec) { try { Config repoConfig = new Config(); // Make up a repo config from the request parameters repoConfig.setString("remote", name, "url", refUrl); List<String> str = new ArrayList<>(); if(refSpec != null && refSpec.length > 0) for (RefSpec rs: refSpec) str.add(rs.toString()); repoConfig.setStringList("remote", name, "fetch", str); return RemoteConfig.getAllRemoteConfigs(repoConfig).get(0); } catch (Exception ex) { throw new GitException("Error trying to create JGit configuration", ex); } }
@Nonnull List<UserRemoteConfig> getRemotes(@Nonnull GitLabSCMSource source) throws GitLabAPIException { return singletonList( new UserRemoteConfig( getProject(projectId, source).getRemote(source), "origin", getRefSpec().delegate().toString(), source.getCredentialsId())); }
/** * @return the {@link UserRemoteConfig} instances. * @deprecated use {@link GitSCMBuilder#asRemoteConfigs()} */ @Deprecated @Restricted(DoNotUse.class) @RestrictedSince("3.4.0") protected List<UserRemoteConfig> getRemoteConfigs() { List<RefSpec> refSpecs = getRefSpecs(); List<UserRemoteConfig> result = new ArrayList<>(refSpecs.size()); String remote = getRemote(); for (RefSpec refSpec : refSpecs) { result.add(new UserRemoteConfig(remote, getRemoteName(), refSpec.toString(), getCredentialsId())); } return result; }
private RemoteConfig newRemoteConfig(String name, String refUrl, RefSpec refSpec, String relativeTargetDir) { try { Config repoConfig = new Config(); // Make up a repo config from the request parameters repoConfig.setString(GitRepository.REMOTE_SECTION, name, "url", refUrl); repoConfig.setString(GitRepository.REMOTE_SECTION, name, "fetch", refSpec.toString()); repoConfig.setString(GitRepository.REMOTE_SECTION, name, GitRepository.TARGET_DIR_KEY, relativeTargetDir); return GitRepository.getAllGitRepositories(repoConfig).get(0); } catch (Exception ex) { throw new GitException("Remote's configuration is invalid", ex); } }
refspec = cfg.getFetchRefSpecs().get(0).toString();
/** * 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); }
/** {@inheritDoc} */ public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException { listener.getLogger().println( "Fetching upstream changes" + (remoteName != null ? " from " + remoteName : "")); ArgumentListBuilder args = new ArgumentListBuilder(); args.add("fetch", "-t"); if (USE_FORCE_FETCH && isAtLeastVersion(2, 20, 0, 0)) { /* CLI git 2.20.0 fixed a long-standing bug that now requires --force to update existing tags */ args.add("--force"); } if (remoteName == null) remoteName = getDefaultRemote(); String url = getRemoteUrl(remoteName); if (url == null) throw new GitException("remote." + remoteName + ".url not defined"); args.add(url); if (refspec != null && refspec.length > 0) for (RefSpec rs: refspec) if (rs != null) args.add(rs.toString()); StandardCredentials cred = credentials.get(url); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, url); }
/** * 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); }
/** * {@inheritDoc} */ @NonNull @Override public SCM build(@NonNull SCMHead head, @CheckForNull SCMRevision revision) { GitSCMBuilder<?> builder = newBuilder(head, revision); if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getExtensions")) { builder.withExtensions(getExtensions()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getBrowser")) { builder.withBrowser(getBrowser()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getGitTool")) { builder.withGitTool(getGitTool()); } if (MethodUtils.isOverridden(AbstractGitSCMSource.class, getClass(), "getRefSpecs")) { List<String> specs = new ArrayList<>(); for (RefSpec spec: getRefSpecs()) { specs.add(spec.toString()); } builder.withoutRefSpecs().withRefSpecs(specs); } builder.withTraits(getTraits()); decorate(builder); return builder.build(); }
for (RefSpec rs: refspecs) if (rs != null) args.add(rs.toString());
.bind( UIText.SimpleConfigurePushDialog_InvalidRefDialogMessage, spec.toString()))) config.addPushRefSpec(spec);
.bind( UIText.SimpleConfigureFetchDialog_InvalidRefDialogMessage, spec.toString()))) config.addFetchRefSpec(spec);
getLogger().info( "push changes to remote... " + refSpec.toString() ); JGitUtils.push( getLogger(), git, (GitScmProviderRepository) repo, refSpec );