command.setCredentialsProvider(credentialsProvider); command.setCredentialsProvider(new UsernamePasswordCredentialsProvider( credentials.valueOfIndex("username").toString(), credentials.valueOfIndex("password").toString()
PullCommand pull(Git git) { return git.pull().setCredentialsProvider(this.provider) .setTransportConfigCallback(this.callback); }
private void pull() throws GitAPIException { Lock writeLock = repositoryLock.writeLock(); try { writeLock.lock(); // TODO: Consider changing merge strategy PullCommand pullCommand = git.pull().setStrategy(MergeStrategy.RECURSIVE); if (StringUtils.isNotBlank(login)) { pullCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(login, password)); } PullResult pullResult = pullCommand.call(); if (!pullResult.isSuccessful()) { throw new IllegalStateException("Can't pull: " + pullResult.toString()); } } finally { writeLock.unlock(); } }
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(); }
@Override public Void call() { try { /** git pull is preferable since it's more efficient **/ LOGGER.debug("Started refresh with git pull"); final PullResult result = getGit().pull().setProgressMonitor(PROGRESS_MONITOR).setRebase(true).setCredentialsProvider(user).call(); if (!result.isSuccessful()) { /** if git pull failed, use git reset **/ LOGGER.info("refresh failed. Running undo local changes"); undoLocalChanges(); } LOGGER.debug("Finished refresh"); } catch (final Exception e) { LOGGER.error("Error when refreshing git directory " + workspaceProvider.getRootDirectory(), e); } return null; } });
@Override public Void call() { try { /** git pull is preferable since it's more efficient **/ LOGGER.debug("Started refresh with git pull"); final PullResult result = getGit().pull().setProgressMonitor(PROGRESS_MONITOR).setRebase(true).setCredentialsProvider(user).call(); if (!result.isSuccessful()) { /** if git pull failed, use git reset **/ LOGGER.info("refresh failed. Running undo local changes"); undoLocalChanges(); } LOGGER.debug("Finished refresh"); } catch (final Exception e) { LOGGER.error("Error when refreshing git directory " + workspaceProvider.getRootDirectory(), e); } return null; } });
/** * Pull repository from current branch and remote branch with same name as current * * @param git * instance. * @param remote * to be used. * @param remoteBranch * to use. * @param username * to connect * @param password * to connect */ public PullResult pullFromRepository(Git git, String remote, String remoteBranch, String username, String password) { try { return git.pull() .setRemote(remote) .setRemoteBranchName(remoteBranch) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
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; }
private Git pull(Git git) throws GitAPIException { if (remoteBranchExists(git)) { PullResult result = git.pull().setStrategy(MergeStrategy.RECURSIVE).setCredentialsProvider(this.credentialsProvider()).call(); if (result.isSuccessful()) { return git; } else { log.info("*** pulling git, not able to merge with MergeStrategy.RECURSIVE go for MergeStrategy.THEIRS"); result = git.pull().setStrategy(MergeStrategy.THEIRS).setCredentialsProvider(this.credentialsProvider()).call(); if(result.isSuccessful()){ return git; } throw new GitException("Pull failed: " + result.toString()); } } else { return git; } }
@Override public synchronized void resolveProperties(ContainerCreationContext context) { try { git.pull().setCredentialsProvider(cp).call(); log.info("repo {} was updated", gitDirPath); String clusterName = context.getCluster(); String imageNameWithoutPrefix = ContainerUtils.getImageNameWithoutPrefix(context.getImageName()); String imageVersionName = ContainerUtils.getImageVersionName(context.getImageName()); String path = gitDirPath + File.separator + clusterName + File.separator; parser.forEach(ps -> { // search in base dir w/o version ps.parse(imageNameWithoutPrefix, context); // search in base dir with version ps.parse(imageVersionName, context); // search in cluster dir w/o version ps.parse(path + imageNameWithoutPrefix, context); // search in cluster dir with version ps.parse(path + imageVersionName, context); context.getContainerName().ifPresent(name -> ps.parse(name, context)); }); } catch (Exception e) { log.error("", e); } }
protected void doPull() { CredentialsProvider cp = getCredentials(); try { Repository repository = git.getRepository(); StoredConfig config = repository.getConfig(); String url = config.getString("remote", "origin", "url"); if (Strings.isBlank(url)) { logPull("No remote repository defined for the git repository at " + getRootGitDirectory().getCanonicalPath() + " so not doing a pull"); return; } String branch = repository.getBranch(); String mergeUrl = config.getString("branch", branch, "merge"); if (Strings.isBlank(mergeUrl)) { logPull("No merge spec for branch." + branch + ".merge in the git repository at " + getRootGitDirectory().getCanonicalPath() + " so not doing a pull"); return; } logPull("Performing a pull in git repository " + getRootGitDirectory().getCanonicalPath() + " on remote URL: " + url); git.pull().setCredentialsProvider(cp).setRebase(true).call(); } catch (Throwable e) { String credText = ""; if (cp instanceof UsernamePasswordCredentialsProvider) { } LOG.error("Failed to pull from the remote git repo with credentials " + cp + " due: " + e.getMessage() + ". This exception is ignored.", e); } finally { firstPull = false; } }
@Override public Void call() { try { final PullResult result = gitProctorCore.getGit() .pull() .setProgressMonitor(PROGRESS_MONITOR) .setRebase(true) .setCredentialsProvider(user) .setTimeout(GitProctorUtils.DEFAULT_GIT_PULL_PUSH_TIMEOUT_SECONDS) .call(); if (!result.isSuccessful()) { /** if git pull failed, use git reset **/ gitProctorCore.undoLocalChanges(); } } catch (final Exception e) { LOGGER.error("Error when refreshing git directory " + getDirectoryPath(), e); } return null; } });
@Override public Void call() { try { final PullResult result = gitProctorCore.getGit() .pull() .setProgressMonitor(PROGRESS_MONITOR) .setRebase(true) .setCredentialsProvider(user) .setTimeout(GitProctorUtils.DEFAULT_GIT_PULL_PUSH_TIMEOUT_SECONDS) .call(); if (!result.isSuccessful()) { /** if git pull failed, use git reset **/ gitProctorCore.undoLocalChanges(); } } catch (final Exception e) { LOGGER.error("Error when refreshing git directory " + getDirectoryPath(), e); } return null; } });
/** * Pull-rebase and push to the remote repo if git.remote is enabled * * @throws GitAPIException If there is a failure talking to the remote repository */ public void push() throws GitAPIException { if (remote) { synchronized (gitDir) { if (haveRemoteBranch()) { git.pull().setCredentialsProvider(provider).setRebase(true).call(); } git.push().setCredentialsProvider(provider).setRemote("origin").call(); } } }
protected void doPull(Exchange exchange, String operation) throws Exception { PullResult result = null; try { if (ObjectHelper.isEmpty(endpoint.getRemoteName())) { throw new IllegalArgumentException("Remote name must be specified to execute " + operation); } if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) { git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call(); } if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) { UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword()); result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemoteName()).call(); } else { result = git.pull().setRemote(endpoint.getRemoteName()).call(); } } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, result); }
public void pullRepo(String uri, String branch, GitUser user) { try { setRemote(uri); git.pull().setRemote(REMOTE_NAME).setRemoteBranchName(branch).setRebase(false) .setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getUsername(), user.getPassword())).call(); } catch (InvalidRemoteException e) { e.printStackTrace(); } catch (TransportException e) { e.printStackTrace(); } catch (GitAPIException e) { e.printStackTrace(); } }
String current = git.getRepository().getBranch(); if (branch.equalsIgnoreCase(current)) { PullResult pull = git.pull().setRemote(remote).setCredentialsProvider(credentialProvider) .setTransportConfigCallback(transportConfigCallback).call(); if (!pull.isSuccessful()) {
String current = git.getRepository().getBranch(); if (branch.equalsIgnoreCase(current)) { PullResult pull = git.pull().setRemote(remote).setCredentialsProvider(credentialProvider) .setTransportConfigCallback(transportConfigCallback).call(); if (!pull.isSuccessful()) {