/** * 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; }
/** * 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); }
/** * Apply provided remote configuration on this transport. * * @param cfg * configuration to apply on this transport. */ public void applyConfig(RemoteConfig cfg) { setOptionUploadPack(cfg.getUploadPack()); setOptionReceivePack(cfg.getReceivePack()); setTagOpt(cfg.getTagOpt()); fetch = cfg.getFetchRefSpecs(); push = cfg.getPushRefSpecs(); timeout = cfg.getTimeout(); }
ConfigConstants.CONFIG_KEY_MERGE); List<RefSpec> fetchRefSpecs = remoteConfig .getFetchRefSpecs(); for (RefSpec refSpec : fetchRefSpecs) { if (refSpec.matchSource(remoteBranchName)) {
/** {@inheritDoc} */ @Deprecated public void fetch(RemoteConfig remoteRepository) throws InterruptedException { // Assume there is only 1 URL for simplicity fetch(remoteRepository.getURIs().get(0), remoteRepository.getFetchRefSpecs()); }
public RemoteConfig getSubmoduleRepository(IGitAPI parentGit, RemoteConfig orig, String name) throws GitException { // The first attempt at finding the URL in this new code relies on // submoduleInit, submoduleSync, fixSubmoduleUrls already being executed // since the last fetch of the super project. (This is currently done // by calling git.setupSubmoduleUrls(...). ) String refUrl = parentGit.getSubmoduleUrl(name); return newRemoteConfig(name, refUrl, orig.getFetchRefSpecs().get(0), StringUtils.EMPTY); }
/** * {@inheritDoc} */ @Override public void decorateCloneCommand(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, CloneCommand cmd) throws IOException, InterruptedException, GitException { listener.getLogger() .printf("Cloning with configured refspecs honoured and %s tags%n", includeTags ? "with" : "without"); RemoteConfig rc = scm.getRepositories().get(0); List<RefSpec> refspecs = rc.getFetchRefSpecs(); cmd.refspecs(refspecs); cmd.tags(includeTags); }
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; }
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 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); }
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$ }
if (config.getFetchRefSpecs().isEmpty() && !repository.getConfig() .getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION)
@Override public boolean canFinish() { if (getContainer().getCurrentPage() == repoPage) { RepositorySelection sel = repoPage.getSelection(); if (sel.isConfigSelected()) { RemoteConfig config = sel.getConfig(); return !config.getURIs().isEmpty() && !config.getFetchRefSpecs().isEmpty(); } } return super.canFinish(); }
List<RefSpec> refspecs = rc.getFetchRefSpecs(); cmd.refspecs(refspecs);
private void addBranchItemsForRemote(String remote) throws IOException, URISyntaxException { RemoteConfig remoteConfig = new RemoteConfig(myConfig, remote); List<RefSpec> fetchSpecs = remoteConfig.getFetchRefSpecs(); if (fetchSpecs.isEmpty()) { return; } Collection<Ref> allRefs = myRepository.getRefDatabase() .getRefs(Constants.R_REFS).values(); for (Ref ref : allRefs) { for (RefSpec fetchSpec : fetchSpecs) { // Fetch specs map remote ref names (source) to local ref names // (destination). We want to get remote ref names, so expand // destination to source. if (fetchSpec.matchDestination(ref)) { RefSpec source = fetchSpec.expandFromDestination(ref); String refNameOnRemote = source.getSource(); branchText.add(refNameOnRemote); } } } }
/** * 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; }
/** * 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); }
/** * Apply provided remote configuration on this transport. * * @param cfg * configuration to apply on this transport. */ public void applyConfig(final RemoteConfig cfg) { setOptionUploadPack(cfg.getUploadPack()); setOptionReceivePack(cfg.getReceivePack()); setTagOpt(cfg.getTagOpt()); fetch = cfg.getFetchRefSpecs(); push = cfg.getPushRefSpecs(); timeout = cfg.getTimeout(); }
/** * Apply provided remote configuration on this transport. * * @param cfg * configuration to apply on this transport. */ public void applyConfig(RemoteConfig cfg) { setOptionUploadPack(cfg.getUploadPack()); setOptionReceivePack(cfg.getReceivePack()); setTagOpt(cfg.getTagOpt()); fetch = cfg.getFetchRefSpecs(); push = cfg.getPushRefSpecs(); timeout = cfg.getTimeout(); }