/** * Push all changes and tags to given remote. * * @param git * instance. * @param remote * to be used. * * @return List of all results of given push. */ public Iterable<PushResult> pushToRepository(Git git, String remote) { try { return git.push() .setRemote(remote) .setPushAll() .setPushTags() .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
/** * Push all changes and tags to given remote. * * @param git * instance. * @param remote * to be used. * @param username * to login. * @param password * to login. * * @return List of all results of given push. */ public Iterable<PushResult> pushToRepository(Git git, String remote, String username, String password) { try { return git.push() .setRemote(remote) .setPushAll() .setPushTags() .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
@Override public Object call(Git git, GitContext context) throws Exception { ProfileRegistry registry = fabricService.adapt(ProfileRegistry.class); Map<String, String> properties = registry.getDataStoreProperties(); String username; String password; if (properties != null && properties.containsKey("gitRemoteUser") && properties.containsKey("gitRemotePassword")) { username = properties.get("gitRemoteUser"); password = properties.get("gitRemotePassword"); } else { username = ZooKeeperUtils.getContainerLogin(runtimeProperties); password = ZooKeeperUtils.generateContainerToken(runtimeProperties, curator); } remoteUrl[0] = git.getRepository().getConfig().getString("remote", "origin", "url"); Iterable<PushResult> results = git.push() .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) .setPushTags() .setPushAll() .call(); logPushResult(results, git.getRepository(), verbose); return null; } };
return git.push() .setRemote(remote) .setPushAll() .setPushTags() .setTransportConfigCallback(transport -> {
public void execute() throws InvalidRemoteException { try { final List<RefSpec> specs = new UpdateRemoteConfig(git, remote, refSpecs).execute(); git._push() .setCredentialsProvider(credentialsProvider) .setRefSpecs(specs) .setRemote(remote.getK1()) .setForce(force) .setPushAll() .call(); } catch (final InvalidRemoteException e) { throw e; } catch (final Exception ex) { throw new RuntimeException(ex); } } }
public URI push(File source, String name) throws Exception { init(); File gitRoot = new File("target", name); FileUtils.copyDirectory(source, gitRoot); // Push via port forward String repoUrl = String.format("http://localhost:%s/%s", GIT_LOCALPORT, name); Git git = Git.init().setDirectory(gitRoot).call(); Repository repo = git.getRepository(); repo.getConfig().setString("remote", "origin", "url", repoUrl); repo.getConfig().save(); git.add().addFilepattern(".").call(); git.commit().setMessage("testing").setAuthor("Arquillian", "cube@discuss.arquillian.org").call(); git.push().setRemote("origin").setPushAll().setForce(true).call(); repo.close(); // Return an internal service name, for use within the openshift network String serverUrl = String.format("http://%s:%s/%s", GIT_SERVICE, GIT_REMOTEPORT, name); return URI.create(serverUrl); }
/** * Creates a branch in the remote repository from which the the current git repository was cloned. * The branch is created from the commit passed and given the name that is passed in. * * @param commit - RevCommit that is to be pushed. * @param submitName - The name of the remote branch to be created. * @throws GitAPIException - failed * @throws IOException - failed */ public void createPullRequest(final RevCommit commit, final String submitName) throws GitAPIException, IOException { markAsSubmitted(commit); git.push() .setRemote("origin") .setPushAll() .setForce(true) .setRefSpecs(new RefSpec("HEAD:refs/heads/" + submitName)) .call(); }
Exception lastException = null; try { resit = git.push().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setPushAll().call().iterator(); } catch (GitAPIException | JGitInternalException ex) { lastException = ex;
org.eclipse.jgit.api.PushCommand push = git.push(); push.setPushAll().setPushTags(); push.setRemote(remoteUrl);
.setPushAll() .call().iterator(); } catch (Exception ex) {
.setRemote(mRemote); if (mPushAll) { pushCommand.setPushAll(); } else { RefSpec spec = new RefSpec(mRepo.getBranchName());
@Override protected void run() throws Exception { Git git = new Git(db); PushCommand push = git.push(); push.setDryRun(dryRun); push.setForce(force); push.setProgressMonitor(new TextProgressMonitor()); push.setReceivePack(receivePack); push.setRefSpecs(refSpecs); if (all) push.setPushAll(); if (tags) push.setPushTags(); push.setRemote(remote); push.setThin(thin); push.setTimeout(timeout); Iterable<PushResult> results = push.call(); for (PushResult result : results) { ObjectReader reader = db.newObjectReader(); try { printPushResult(reader, result.getURI(), result); } finally { reader.release(); } } }
.setRemote(mRemote); if (mPushAll) { pushCommand.setPushAll(); } else { RefSpec spec = new RefSpec(mRepo.getBranchName());