private String retrieveRevisionToBuild(PushHook hook, GitSCM gitSCM) throws NoRevisionToBuildException { if (inNoBranchDelete(hook)) { if (gitSCM != null && gitSCM.getRepositories().size() == 1) { String repositoryName = gitSCM.getRepositories().get(0).getName(); return hook.getRef().replaceFirst("^refs/heads", "remotes/" + repositoryName); } else { return hook.getAfter(); } } else { throw new NoRevisionToBuildException(); } }
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 void unset(Config rc, String key) { rc.unset(SECTION, getName(), key); }
private void set(final Config rc, final String key, final String currentValue, final String defaultValue) { if (defaultValue.equals(currentValue)) unset(rc, key); else rc.setString(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final boolean currentValue, final boolean defaultValue) { if (defaultValue == currentValue) unset(rc, key); else rc.setBoolean(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final int currentValue, final int defaultValue) { if (defaultValue == currentValue) unset(rc, key); else rc.setInt(SECTION, getName(), key, currentValue); }
/** * Open new transport instances to connect two repositories. * * @param local * existing local repository. * @param cfg * configuration describing how to connect to the remote * repository. * @param op * planned use of the returned Transport; the URI may differ * based on the type of connection desired. * @return the list of new transport instances for every URI in remote * configuration. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ public static List<Transport> openAll(final Repository local, final RemoteConfig cfg, final Operation op) throws NotSupportedException, TransportException { final List<URIish> uris = getURIs(cfg, op); final List<Transport> transports = new ArrayList<>(uris.size()); for (URIish uri : uris) { final Transport tn = open(local, uri, cfg.getName()); tn.applyConfig(cfg); transports.add(tn); } return transports; }
/** * 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 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() + '/') + '*'; boolean fetchAll = cloneAllBranches || branchesToClone == null || branchesToClone.isEmpty(); config.setFetchRefSpecs(calculateRefSpecs(fetchAll, dst)); config.update(clonedRepo.getConfig()); clonedRepo.getConfig().save(); // run the fetch command FetchCommand command = new FetchCommand(clonedRepo); command.setRemote(remote); command.setProgressMonitor(monitor); command.setTagOpt(fetchAll ? TagOpt.FETCH_TAGS : TagOpt.AUTO_FOLLOW); configure(command); return command.call(); }
private RemoteConfig selectDefaultRemoteConfig() { if (configuredRemotes == null) return null; for (final RemoteConfig rc : configuredRemotes) if (Constants.DEFAULT_REMOTE_NAME.equals(rc.getName())) return rc; return configuredRemotes.get(0); }
/** * @return selected remote configuration name or null if selection is not a * remote configuration. */ public String getConfigName() { if (isConfigSelected()) return config.getName(); return null; }
/** {@inheritDoc} */ @Deprecated @Override public void push(RemoteConfig repository, String refspec) throws GitException, InterruptedException { push(repository.getName(),refspec); }
private void set(final Config rc, final String key, final String currentValue, final String defaultValue) { if (defaultValue.equals(currentValue)) unset(rc, key); else rc.setString(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final String currentValue, final String defaultValue) { if (defaultValue.equals(currentValue)) unset(rc, key); else rc.setString(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final int currentValue, final int defaultValue) { if (defaultValue == currentValue) unset(rc, key); else rc.setInt(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final int currentValue, final int defaultValue) { if (defaultValue == currentValue) unset(rc, key); else rc.setInt(SECTION, getName(), key, currentValue); }
private void set(final Config rc, final String key, final boolean currentValue, final boolean defaultValue) { if (defaultValue == currentValue) unset(rc, key); else rc.setBoolean(SECTION, getName(), key, currentValue); }
public String getBranchNameWithoutRemote(String branchName) { List<RemoteConfig> repositories = getJenkinsScm().getRepositories(); for (RemoteConfig remoteConfig : repositories) { String prefix = remoteConfig.getName() + "/"; if (branchName.startsWith(prefix)) { return StringUtils.removeStart(branchName, prefix); } } return branchName; }
@Override public void create() { super.create(); setTitle(NLS.bind(UIText.SimpleConfigurePushDialog_DialogTitle, config.getName())); setMessage(UIText.SimpleConfigurePushDialog_DialogMessage); updateControls(); }