private void pull() throws GitAPIException { Git git = recordGit(Git.wrap(repository)); PullCommand pull = git.pull() .setRebase(true); PullResult result = pull.call(); if (!result.isSuccessful()) { LOGGER.log(Level.WARNING, () -> String.format("Cannot pull from git '%s', branch '%s'", uri.toASCIIString(), branch)); if (LOGGER.isLoggable(Level.FINEST)) { Status status = git.status().call(); LOGGER.finest(() -> "git status cleanliness: " + status.isClean()); if (!status.isClean()) { LOGGER.finest(() -> "git status uncommitted changes: " + status.getUncommittedChanges()); LOGGER.finest(() -> "git status untracked: " + status.getUntracked()); } } } else { LOGGER.fine("Pull was successful."); } LOGGER.finest(() -> "git rebase result: " + result.getRebaseResult().getStatus().name()); LOGGER.finest(() -> "git fetch result: " + result.getFetchResult().getMessages()); }
return GitUtils.valueOf(command.call());
public static void main(String[] args) throws IOException, GitAPIException { final File localPath; try (Repository repository = cloneRepository()) { localPath = repository.getWorkTree(); System.out.println("Having repository: " + repository.getDirectory() + " with head: " + repository.findRef(Constants.HEAD) + "/" + repository.resolve("HEAD") + "/" + repository.resolve("refs/heads/master")); // TODO: why do we get null here for HEAD?!? See also // http://stackoverflow.com/questions/17979660/jgit-pull-noheadexception try (Git git = new Git(repository)) { PullResult call = git.pull().call(); System.out.println("Pulled from the remote repository: " + call); } } // clean up here to not keep using more and more disk-space for these samples FileUtils.deleteDirectory(localPath); }
public static void main(String[] args) throws IOException, GitAPIException { final File localPath; try (Repository repository = cloneRepository()) { localPath = repository.getWorkTree(); System.out.println("Having repository: " + repository.getDirectory() + " with head: " + repository.findRef(Constants.HEAD) + "/" + repository.resolve("HEAD") + "/" + repository.resolve("refs/heads/master")); // TODO: why do we get null here for HEAD?!? See also // http://stackoverflow.com/questions/17979660/jgit-pull-noheadexception try (Git git = new Git(repository)) { PullResult call = git.pull().call(); System.out.println("Pulled from the remote repository: " + call); } } // clean up here to not keep using more and more disk-space for these samples FileUtils.deleteDirectory(localPath); }
public static void main(String[] args) throws IOException, GitAPIException { // prepare a new folder for the cloned repository File localPath = File.createTempFile("TestGitRepository", ""); if(!localPath.delete()) { throw new IOException("Could not delete temporary file " + localPath); } // then clone System.out.println("Cloning from " + REMOTE_URL + " to " + localPath); try (Git result = Git.cloneRepository() .setURI(REMOTE_URL) .setDirectory(localPath) .call()) { // Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks! System.out.println("Having repository: " + result.getRepository().getDirectory()); try (Git git = new Git(result.getRepository())) { git.pull() .call(); } System.out.println("Pulled from remote repository to local repository at " + result.getRepository().getDirectory()); } // clean up here to not keep using more and more disk-space for these samples FileUtils.deleteDirectory(localPath); } }
public static void main(String[] args) throws IOException, GitAPIException { // prepare a new folder for the cloned repository File localPath = File.createTempFile("TestGitRepository", ""); if(!localPath.delete()) { throw new IOException("Could not delete temporary file " + localPath); } // then clone System.out.println("Cloning from " + REMOTE_URL + " to " + localPath); try (Git result = Git.cloneRepository() .setURI(REMOTE_URL) .setDirectory(localPath) .call()) { // Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks! System.out.println("Having repository: " + result.getRepository().getDirectory()); try (Git git = new Git(result.getRepository())) { git.pull() .call(); } System.out.println("Pulled from remote repository to local repository at " + result.getRepository().getDirectory()); } // clean up here to not keep using more and more disk-space for these samples FileUtils.deleteDirectory(localPath); } }
@Override public void pull(String branch, ProgressMonitor monitor) throws GitException { try (Git git = gitOpen()) { PullCommand pullCommand = pullCommand(branch, git); if (monitor != null) { pullCommand.setProgressMonitor(monitor); } else { pullCommand.setProgressMonitor(new DebugProgressMonitor()); } pullCommand.call(); } catch (Throwable e) { throw new GitException("Fail to pull with specific files: " + ExceptionUtil.findRootCause(e).getMessage()); } }
private void reload() { try { LOG.debug("Reloading configuration by pulling changes"); clonedRepo.pull().call(); } catch (GitAPIException e) { initialized = false; throw new IllegalStateException("Unable to pull from remote repository", e); } }
public PullResult pull(Git git) throws GitAPIException { return git.pull().call(); }
public boolean pull() throws Exception { log.debug("Pulling latest updates from remote git repo"); return git.pull().call().isSuccessful(); }
/** * Pulls changes form the default remote repository into the wrapped repository. * * @throws GitAPIException - failed. */ public void pull() throws GitAPIException { if (!isUndefined()) { git.pull().call(); } }
@Override public PullResult pull(final Git git, final int timeout) throws GitAPIException { PullCommand pull = git.pull(); if (timeout >= 0) pull.setTimeout(timeout); pull.setProgressMonitor(new TextProgressMonitor()); PullResult result = pull.call(); return result; }
protected void doPull(Git git, GitContext context) throws GitAPIException { StopWatch watch = new StopWatch(); LOG.info("Performing a pull in git repository " + this.gitFolder + " on remote URL: " + this.remoteRepository); CredentialsProvider cp = userDetails.createCredentialsProvider(); PullCommand command = git.pull(); configureCommand(command, userDetails); command.setCredentialsProvider(cp).setRebase(true).call(); LOG.info("Took " + watch.taken() + " to complete pull in git repository " + this.gitFolder + " on remote URL: " + this.remoteRepository); }
public void pull(String branch) throws Exception { PullCommand pull = git.pull().setRemote("origin").setRemoteBranchName(branch); if (credentialsProvider != null) pull.setCredentialsProvider(credentialsProvider); pull.call(); }
private Collection<String> attemptRebase() throws GitAPIException { val conflicts = new HashSet<String>(); createStashIfNeeded(); val pr = git.pull().setStrategy(MergeStrategy.RESOLVE).setRebase(true).call(); if (pr.getRebaseResult().getConflicts() != null) { conflicts.addAll(pr.getRebaseResult().getConflicts()); } conflicts.addAll(applyStashIfNeeded()); return conflicts; }
private Git pullRepository(final File workingDir) throws GitAPIException, IOException { final Git git = Git.open(workingDir); git.pull().setProgressMonitor(PROGRESS_MONITOR) .setRebase(true) .setCredentialsProvider(user) .setTimeout(pullPushTimeoutSeconds) .call(); return git; }
private Git pullRepository(final File workingDir) throws GitAPIException, IOException { final Git git = Git.open(workingDir); git.pull().setProgressMonitor(PROGRESS_MONITOR) .setRebase(true) .setCredentialsProvider(user) .setTimeout(pullPushTimeoutSeconds) .call(); return git; }
public void pullRepo() { try { git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(MASTER_BRANCH).setRebase(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
public static void updateRepo(File directory) throws GitAPIException { if (getGit() != null) { getGit().pull().call(); } else { Git.cloneRepository().setDirectory(directory).setURI("https://github.com/FlareBot/FlareBot.git").call(); } }
public void pullRepo(String uri, String branch) { try { setRemote(uri); git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(branch).setRebase(false).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }