use of org.eclipse.egit.core.op.FetchOperation in project jbosstools-openshift by jbosstools.
the class EGitUtils method fetch.
/**
* Fetches the source ref(s) (from the given ref spec(s)) from the given uri
* to the given destination(s) (in the given ref spec(s)) to the given
* repository.
*
* @param uri
* the uri to fetch from
* @param fetchRefsRefSpecs
* the references with the sources and destinations
* @param repository
* the repository to fetch to
* @param monitor
* the monitor to report progress to
* @return
* @throws InvocationTargetException
* @throws CoreException
*/
private static Collection<Ref> fetch(URIish uri, List<RefSpec> fetchRefsRefSpecs, Repository repository, IProgressMonitor monitor) throws InvocationTargetException, CoreException {
FetchOperation fetch = new FetchOperation(repository, uri, fetchRefsRefSpecs, 10 * 1024, false);
fetch.run(monitor);
FetchResult result = fetch.getOperationResult();
return result.getAdvertisedRefs();
}
use of org.eclipse.egit.core.op.FetchOperation in project jbosstools-openshift by jbosstools.
the class EGitUtils method fetch.
/**
* Fetches according to the fetch specs in the given remote config to the
* given repo. If the given remote config has no fetch spec, then
* +refs/heads/*:refs/remotes/<remote-name>/* is used
*
* @param config
* the remote config to use when fetching
* @param repo
* the repo to fetch to
* @param monitor
* the monitor to report progress to
* @return
* @throws InvocationTargetException
*/
public static FetchResult fetch(RemoteConfig config, Repository repo, IProgressMonitor monitor) throws InvocationTargetException {
if (config != null && !config.getFetchRefSpecs().isEmpty()) {
FetchOperation op = new FetchOperation(repo, config, getEgitTimeout(), false);
op.run(monitor);
return op.getOperationResult();
} else {
List<RefSpec> refSpecs = Arrays.asList(new RefSpec(String.format(DEFAULT_FETCH_REMOTE_REFSPEC, config.getName())));
return fetch(config, refSpecs, repo, monitor);
}
}
use of org.eclipse.egit.core.op.FetchOperation in project jbosstools-openshift by jbosstools.
the class EGitUtils method fetch.
/**
* Fetches the given ref specs from the given remote configs in the given repository.
*
* @param config
* @param refSpecs
* @param repo
* @param monitor
* @return
* @throws InvocationTargetException
*
* @see RemoteConfig
* @see RefSpec
* @see Repository
*/
public static FetchResult fetch(RemoteConfig config, List<RefSpec> refSpecs, Repository repo, IProgressMonitor monitor) throws InvocationTargetException {
URIish fetchURI = getFetchURI(config);
FetchOperation op = new FetchOperation(repo, fetchURI, refSpecs, getEgitTimeout(), false);
op.run(monitor);
return op.getOperationResult();
}
use of org.eclipse.egit.core.op.FetchOperation in project egit by eclipse.
the class SynchronizeViewPushTest method prepare.
@Before
public void prepare() throws Exception {
Repository childRepository = lookupRepository(childRepositoryFile);
Repository repository = lookupRepository(repositoryFile);
StoredConfig config = repository.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL()));
remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
remoteConfig.update(config);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE, "origin");
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/master");
config.save();
FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false);
fetchOperation.run(null);
}
use of org.eclipse.egit.core.op.FetchOperation in project egit by eclipse.
the class GitFlowOperation method fetch.
/**
* Fetch using the default remote configuration
*
* @param monitor
* @param timeout
* timeout in seconds
* @return result of fetching from remote
* @throws URISyntaxException
* @throws InvocationTargetException
*
* @since 4.2
*/
protected FetchResult fetch(IProgressMonitor monitor, int timeout) throws URISyntaxException, InvocationTargetException {
RemoteConfig config = repository.getConfig().getDefaultRemoteConfig();
FetchOperation fetchOperation = new FetchOperation(repository.getRepository(), config, timeout, false);
fetchOperation.run(monitor);
return fetchOperation.getOperationResult();
}
Aggregations