Java Code Examples for org.eclipse.jgit.api.PullCommand#call()
The following examples show how to use
org.eclipse.jgit.api.PullCommand#call() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OldGitHubNotebookRepo.java From zeppelin with Apache License 2.0 | 7 votes |
private void pullFromRemoteStream() { try { LOG.debug("Pulling latest changes from remote stream"); PullCommand pullCommand = git.pull(); pullCommand.setCredentialsProvider( new UsernamePasswordCredentialsProvider( zeppelinConfiguration.getZeppelinNotebookGitUsername(), zeppelinConfiguration.getZeppelinNotebookGitAccessToken() ) ); pullCommand.call(); } catch (GitAPIException e) { LOG.error("Error when pulling latest changes from remote repository", e); } }
Example 2
Source File: GitHubNotebookRepo.java From zeppelin with Apache License 2.0 | 6 votes |
private void pullFromRemoteStream() { try { LOG.debug("Pulling latest changes from remote stream"); PullCommand pullCommand = git.pull(); pullCommand.setCredentialsProvider( new UsernamePasswordCredentialsProvider( zeppelinConfiguration.getZeppelinNotebookGitUsername(), zeppelinConfiguration.getZeppelinNotebookGitAccessToken() ) ); pullCommand.call(); } catch (GitAPIException e) { LOG.error("Error when pulling latest changes from remote repository", e); } }
Example 3
Source File: UpdaterGenerator.java From neembuu-uploader with GNU General Public License v3.0 | 6 votes |
/** * Execute git pull command on the given repository. * It populates an ArrayList with all the updated files. * @param localPath The path where the project is. * @return Returns true if you should update plugins, false otherwise. */ private boolean gitPull(File localPath) { try { Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git"); git = new Git(localRepo); populateDiff(); if(!pluginsToUpdate.isEmpty()){ PullCommand pullCmd = git.pull(); pullCmd.call(); return true; } else{ return false; } } catch (GitAPIException | IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 4
Source File: UpdaterGenerator.java From neembuu-uploader with GNU General Public License v3.0 | 6 votes |
/** * Execute git pull command on the given repository. * It populates an ArrayList with all the updated files. * @param localPath The path where the project is. * @return Returns true if you should update plugins, false otherwise. */ private boolean gitPull(File localPath) { try { Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git"); git = new Git(localRepo); if(populateDiff()){ PullCommand pullCmd = git.pull(); pullCmd.call(); return true; } else{ return false; } } catch (GitAPIException | IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 5
Source File: PullTask.java From ant-git-tasks with Apache License 2.0 | 6 votes |
@Override public void doExecute() { try { PullCommand pullCommand = git.pull().setRebase(rebase); if (getProgressMonitor() != null) { pullCommand.setProgressMonitor(getProgressMonitor()); } setupCredentials(pullCommand); PullResult pullResult = pullCommand.call(); if (!pullResult.isSuccessful()) { FetchResult fetchResult = pullResult.getFetchResult(); GitTaskUtils.validateTrackingRefUpdates(MESSAGE_PULLED_FAILED, fetchResult.getTrackingRefUpdates()); MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus(); if (!mergeStatus.isSuccessful()) { throw new BuildException(String.format(MESSAGE_PULLED_FAILED_WITH_STATUS, mergeStatus.name())); } } } catch (Exception e) { throw new GitBuildException(String.format(MESSAGE_PULLED_FAILED_WITH_URI, getUri()), e); } }
Example 6
Source File: PullJob.java From orion.server with Eclipse Public License 1.0 | 4 votes |
private IStatus doPull(IProgressMonitor monitor) throws IOException, GitAPIException, CoreException { ProgressMonitor gitMonitor = new EclipseGitProgressTransformer(monitor); Repository db = null; try { db = FileRepositoryBuilder.create(GitUtils.getGitDir(path)); Git git = Git.wrap(db); PullCommand pc = git.pull(); pc.setProgressMonitor(gitMonitor); pc.setCredentialsProvider(credentials); pc.setTransportConfigCallback(new TransportConfigCallback() { @Override public void configure(Transport t) { credentials.setUri(t.getURI()); if (t instanceof TransportHttp && cookie != null) { HashMap<String, String> map = new HashMap<String, String>(); map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue()); ((TransportHttp) t).setAdditionalHeaders(map); } } }); PullResult pullResult = pc.call(); if (monitor.isCanceled()) { return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled"); } // handle result if (pullResult.isSuccessful()) { return Status.OK_STATUS; } FetchResult fetchResult = pullResult.getFetchResult(); IStatus fetchStatus = FetchJob.handleFetchResult(fetchResult); if (!fetchStatus.isOK()) { return fetchStatus; } MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus(); if (!mergeStatus.isSuccessful()) return new Status(IStatus.ERROR, GitActivator.PI_GIT, mergeStatus.name()); } finally { if (db != null) { db.close(); } } return Status.OK_STATUS; }
Example 7
Source File: Pull.java From wandora with GNU General Public License v3.0 | 4 votes |
@Override public void execute(Wandora wandora, Context context) { try { Git git = getGit(); if(git != null) { if(isNotEmpty(getGitRemoteUrl())) { PullCommand pull = git.pull(); String user = getUsername(); if(user == null) { if(pullUI == null) { pullUI = new PullUI(); } pullUI.setUsername(getUsername()); pullUI.setPassword(getPassword()); pullUI.setRemoteUrl(getGitRemoteUrl()); pullUI.openInDialog(); if(pullUI.wasAccepted()) { setUsername(pullUI.getUsername()); setPassword(pullUI.getPassword()); // setGitRemoteUrl(pullUI.getRemoteUrl()); // pull.setRemote(pullUI.getRemoteUrl()); if(isNotEmpty(getUsername())) { CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( getUsername(), getPassword() ); pull.setCredentialsProvider(credentialsProvider); } } else { return; } } setDefaultLogger(); setLogTitle("Git pull"); log("Pulling changes from remote repository..."); PullResult result = pull.call(); FetchResult fetchResult = result.getFetchResult(); MergeResult mergeResult = result.getMergeResult(); MergeStatus mergeStatus = mergeResult.getMergeStatus(); String fetchResultMessages = fetchResult.getMessages(); if(isNotEmpty(fetchResultMessages)) { log(fetchResult.getMessages()); } log(mergeStatus.toString()); if(mergeStatus.equals(MergeStatus.MERGED)) { int a = WandoraOptionPane.showConfirmDialog(wandora, "Reload Wandora project after pull?", "Reload Wandora project after pull?", WandoraOptionPane.YES_NO_OPTION); if(a == WandoraOptionPane.YES_OPTION) { reloadWandoraProject(); } } log("Ready."); } else { log("Repository has no remote origin and can't be pulled. " + "Initialize repository by cloning remote repository to set the remote origin."); } } else { logAboutMissingGitRepository(); } } catch(GitAPIException gae) { log(gae.toString()); } catch(NoWorkTreeException nwte) { log(nwte.toString()); } catch(Exception e) { log(e); } setState(WAIT); }