List of usage examples for org.eclipse.jgit.api FetchCommand setTagOpt
public FetchCommand setTagOpt(TagOpt tagOpt)
From source file:org.ajoberstar.gradle.git.tasks.GitFetch.java
License:Apache License
/** * Fetches remote changes into a local Git repository. *///from w w w . j a va 2 s. c o m @TaskAction public void fetch() { FetchCommand cmd = getGit().fetch(); TransportAuthUtil.configure(cmd, this); cmd.setTagOpt(getTagOpt()); cmd.setCheckFetchedObjects(getCheckFetchedObjects()); cmd.setDryRun(getDryRun()); cmd.setRefSpecs(getRefspecs()); cmd.setRemote(getRemote()); cmd.setRemoveDeletedRefs(getRemoveDeletedRefs()); cmd.setThin(getThin()); try { cmd.call(); } catch (InvalidRemoteException e) { throw new GradleException("Invalid remote specified: " + getRemote(), e); } catch (TransportException e) { throw new GradleException("Problem with transport.", e); } catch (GitAPIException e) { throw new GradleException("Problem with fetch.", e); } //TODO add progress monitor to log progress to Gradle status bar }
From source file:org.eclipse.egit.core.op.FetchOperation.java
License:Open Source License
/** * @param monitor/*from w ww.java 2s .c om*/ * @throws InvocationTargetException */ public void run(IProgressMonitor monitor) throws InvocationTargetException { if (operationResult != null) throw new IllegalStateException(CoreText.OperationAlreadyExecuted); IProgressMonitor actMonitor = monitor; if (actMonitor == null) actMonitor = new NullProgressMonitor(); EclipseGitProgressTransformer gitMonitor = new EclipseGitProgressTransformer(actMonitor); FetchCommand command; if (rc == null) command = new Git(repository).fetch().setRemote(uri.toPrivateString()).setRefSpecs(specs); else command = new Git(repository).fetch().setRemote(rc.getName()); command.setCredentialsProvider(credentialsProvider).setTimeout(timeout).setDryRun(dryRun) .setProgressMonitor(gitMonitor); if (tagOpt != null) command.setTagOpt(tagOpt); try { operationResult = command.call(); } catch (JGitInternalException e) { throw new InvocationTargetException(e.getCause() != null ? e.getCause() : e); } catch (Exception e) { throw new InvocationTargetException(e); } }
From source file:org.flowerplatform.web.git.GitService.java
License:Open Source License
@RemoteInvocation public boolean fetch(ServiceInvocationContext context, List<PathFragment> path, RemoteConfig fetchConfig) { tlCommand.set((InvokeServiceMethodServerCommand) context.getCommand()); ProgressMonitor monitor = ProgressMonitor.create( GitPlugin.getInstance().getMessage("git.fetch.monitor.title"), context.getCommunicationChannel()); try {/*from w w w . j a v a2 s . c o m*/ Object node = GenericTreeStatefulService.getNodeByPathFor(path, null); GenericTreeStatefulService service = GenericTreeStatefulService.getServiceFromPathWithRoot(path); NodeInfo nodeInfo = service.getVisibleNodes().get(node); Repository repository = getRepository(nodeInfo); if (repository == null) { context.getCommunicationChannel().appendOrSendCommand(new DisplaySimpleMessageClientCommand( CommonPlugin.getInstance().getMessage("error"), "Cannot find repository for node " + node, DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } String remote = null; if (GitNodeType.NODE_TYPE_REMOTE.equals(nodeInfo.getPathFragment().getType())) { remote = ((RemoteNode) node).getRemote(); } GitProgressMonitor gitMonitor = new GitProgressMonitor(monitor); FetchCommand command; if (remote != null) { command = new Git(repository).fetch().setRemote(remote); } else { List<RefSpec> specs = new ArrayList<RefSpec>(); for (String refMapping : fetchConfig.getFetchMappings()) { specs.add(new RefSpec(refMapping)); } command = new Git(repository).fetch().setRemote(new URIish(fetchConfig.getUri()).toPrivateString()) .setRefSpecs(specs); } command.setProgressMonitor(gitMonitor); command.setTagOpt(TagOpt.FETCH_TAGS); FetchResult fetchResult = command.call(); dispatchContentUpdate(node); context.getCommunicationChannel() .appendOrSendCommand(new DisplaySimpleMessageClientCommand( GitPlugin.getInstance().getMessage("git.fetch.result"), GitPlugin.getInstance().getUtils().handleFetchResult(fetchResult), DisplaySimpleMessageClientCommand.ICON_INFORMATION)); return true; } catch (Exception e) { if (GitPlugin.getInstance().getUtils().isAuthentificationException(e)) { openLoginWindow(); return true; } logger.debug(GitPlugin.getInstance().getMessage("git.fetch.error"), e); context.getCommunicationChannel().appendOrSendCommand( new DisplaySimpleMessageClientCommand(CommonPlugin.getInstance().getMessage("error"), e.getMessage(), DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } finally { monitor.done(); } }
From source file:org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.java
License:Apache License
private FetchResult fetch(Git git, String label) { FetchCommand fetch = git.fetch(); fetch.setRemote("origin"); fetch.setTagOpt(TagOpt.FETCH_TAGS); setTimeout(fetch);/* ww w. ja v a 2 s. co m*/ try { setCredentialsProvider(fetch); FetchResult result = fetch.call(); if (result.getTrackingRefUpdates() != null && result.getTrackingRefUpdates().size() > 0) { logger.info("Fetched for remote " + label + " and found " + result.getTrackingRefUpdates().size() + " updates"); } return result; } catch (Exception ex) { String message = "Could not fetch remote for " + label + " remote: " + git.getRepository().getConfig().getString("remote", "origin", "url"); warn(message, ex); return null; } }