private URIish getFirstRepoURL(List<RemoteConfig> repositories) { if (!repositories.isEmpty()) { List<URIish> uris = repositories.get(repositories.size() - 1).getURIs(); if (!uris.isEmpty()) { return uris.get(uris.size() - 1); } } throw new IllegalStateException(Messages.GitLabPushTrigger_NoSourceRepository()); }
private URIish getFirstRepoURL(List<RemoteConfig> repositories) { if (!repositories.isEmpty()) { List<URIish> uris = repositories.get(repositories.size() - 1).getURIs(); if (!uris.isEmpty()) { return uris.get(uris.size() - 1); } } throw new IllegalStateException(Messages.GitLabPushTrigger_NoSourceRepository()); }
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; }
private static boolean doesNotExist(RemoteConfig cfg) { return cfg.getURIs().isEmpty() && cfg.getPushURIs().isEmpty(); }
private static List<URIish> getURIs(final RemoteConfig cfg, final Operation op) { switch (op) { case FETCH: return cfg.getURIs(); case PUSH: { List<URIish> uris = cfg.getPushURIs(); if (uris.isEmpty()) uris = cfg.getURIs(); return uris; } default: throw new IllegalArgumentException(op.toString()); } }
List<URIish> uris = rc.getPushURIs(); if (uris.isEmpty()) { uris = rc.getURIs();
List<URIish> uris = remote.getURIs(); if (uris.size() > 1) { throw new JGitInternalException(
/** * 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); }
@Override public void widgetSelected(SelectionEvent e) { config.removeURI(config.getURIs().get(0)); updateControls(); } });
private static boolean doesNotExist(final RemoteConfig cfg) { return cfg.getURIs().isEmpty() && cfg.getPushURIs().isEmpty(); }
private URIish getUri() { URIish urIish = null; if (remoteConfig.getPushURIs().size() > 0) urIish = remoteConfig.getPushURIs().get(0); else urIish = remoteConfig.getURIs().get(0); return urIish; }
@Override public String getKey() { String name = getScmName(); if (name != null) { return name; } StringBuilder b = new StringBuilder("git"); for (RemoteConfig cfg : getRepositories()) { for (URIish uri : cfg.getURIs()) { b.append(' ').append(uri.toString()); } } return b.toString(); }
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()); }
private URL getResultFromNamedRepository(GitChangeSet changeSet) throws MalformedURLException { GitSCM scm = getScmFromProject(changeSet); return new URL(scm.getRepositoryByName(getRepoUrl()).getURIs().get(0).toString()); }
/** * 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()])); }
@Override public boolean canFinish() { if (getContainer().getCurrentPage() == repoPage) { RepositorySelection sel = repoPage.getSelection(); if (sel.isConfigSelected()) { RemoteConfig config = sel.getConfig(); return !config.getPushURIs().isEmpty() || !config.getURIs().isEmpty(); } } return super.canFinish(); }
@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(); }
private void addOrigin() throws URISyntaxException, GitAPIException { RemoteAddCommand add = git.remoteAdd(); add.setName("origin"); String uri = "https://example.org/repo"; add.setUri(new URIish(uri)); add.call(); assertEquals("origin", git.remoteList().call().iterator().next().getName()); assertEquals(uri, git.remoteList().call().iterator().next().getURIs().iterator().next().toString()); } }