List of usage examples for org.eclipse.jgit.api PushCommand call
@Override public Iterable<PushResult> call() throws GitAPIException, InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException
Execute the push command with all the options and parameters collected by the setter methods of this class.
From source file:ch.sourcepond.maven.release.scm.git.GitProposedTag.java
License:Apache License
private void pushAndLogResult(final PushCommand pushCommand) throws GitAPIException, InvalidRemoteException, TransportException { for (final PushResult result : pushCommand.call()) { for (final RemoteRefUpdate upd : result.getRemoteUpdates()) { log.info(upd.toString());//from ww w . j a va 2 s . co m } } }
From source file:com.amazonaws.eclipse.elasticbeanstalk.git.AWSGitPushCommand.java
License:Open Source License
public void execute() throws CoreException { Iterable<PushResult> pushResults = null; try {// w w w . jav a 2 s .c om Repository repository = initializeRepository(); // Add the new files clearOutRepository(repository); extractZipFile(archiveFile, repoLocation); commitChanges(repository, "Incremental Deployment: " + new Date().toString()); // Push to AWS String remoteUrl = getRemoteUrl(); if (log.isLoggable(Level.FINE)) log.fine("Pushing to: " + remoteUrl); PushCommand pushCommand = new Git(repository).push().setRemote(remoteUrl).setForce(true).add("master"); // TODO: we could use a ProgressMonitor here for reporting status back to the UI pushResults = pushCommand.call(); } catch (Throwable t) { throwCoreException(null, t); } for (PushResult pushResult : pushResults) { String messages = pushResult.getMessages(); if (messages != null && messages.trim().length() > 0) { throwCoreException(messages, null); } } }
From source file:com.centurylink.mdw.dataaccess.file.VersionControlGit.java
License:Apache License
public void push() throws Exception { PushCommand push = git.push(); if (credentialsProvider != null) push.setCredentialsProvider(credentialsProvider); push.call(); }
From source file:com.chungkwong.jgitgui.RemoteTreeItem.java
License:Open Source License
private void gitPush() { ProgressDialog progressDialog = new ProgressDialog( java.util.ResourceBundle.getBundle("com/chungkwong/jgitgui/text").getString("PUSHING")); PushCommand command = ((Git) getParent().getValue()).push().setRemote(((RemoteConfig) getValue()).getName()) .setProgressMonitor(progressDialog); TextField user = new TextField(); PasswordField pass = new PasswordField(); GridPane auth = new GridPane(); auth.addRow(0,//from w w w .j a v a 2s .c o m new Label(java.util.ResourceBundle.getBundle("com/chungkwong/jgitgui/text").getString("USER")), user); auth.addRow(1, new Label(java.util.ResourceBundle.getBundle("com/chungkwong/jgitgui/text").getString("PASSWORD")), pass); Dialog dialog = new Dialog(); dialog.getDialogPane().setContent(auth); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE, ButtonType.APPLY); dialog.showAndWait(); if (true) { command.setCredentialsProvider(new UsernamePasswordCredentialsProvider(user.getText(), pass.getText())); } new Thread(() -> { try { command.call(); } catch (Exception ex) { Logger.getLogger(GitTreeItem.class.getName()).log(Level.SEVERE, null, ex); Platform.runLater(() -> { progressDialog.hide(); Util.informUser(ex); }); } }).start(); }
From source file:com.cloudcontrolled.cctrl.maven.plugin.push.CloudcontrolledPush.java
License:Apache License
private String push(String remoteLocation) throws MojoExecutionException { Repository repository = null;/*from w w w . ja va2 s . c o m*/ Git git; try { repository = getRepository(); git = Git.wrap(repository); PushCommand pushCommand = git.push(); pushCommand.setRemote(remoteLocation); pushCommand.setRefSpecs(new RefSpec(repository.getFullBranch())); Iterable<PushResult> pushResult = pushCommand.call(); Iterator<PushResult> result = pushResult.iterator(); StringBuffer buffer = new StringBuffer(); if (result.hasNext()) { while (result.hasNext()) { String line = result.next().getMessages(); if (!line.isEmpty()) { buffer.append(line); if (result.hasNext()) { buffer.append(System.getProperty("line.separator")); } } } } return buffer.toString(); } catch (Exception e) { throw new MojoExecutionException(e.getClass().getSimpleName(), e); } finally { if (repository != null) { repository.close(); } } }
From source file:com.google.appraise.eclipse.core.client.git.AppraiseGitReviewClient.java
License:Open Source License
/** * Writes a new {@link Review} based on the given task data. * @return the new review's hash.//from w w w. j a v a2s . c om */ public String createReview(String reviewCommitHash, Review review) throws GitClientException { // Sync to minimize the chances of non-linear merges. syncCommentsAndReviews(); // Push the code under review, or the user won't be able to access the commit with the // notes. try (Git git = new Git(repo)) { assert !"master".equals(review.getReviewRef()); RefSpec reviewRefSpec = new RefSpec(review.getReviewRef()); PushCommand pushCommand = git.push(); pushCommand.setRefSpecs(reviewRefSpec); try { pushCommand.call(); } catch (Exception e) { throw new GitClientException("Error pushing review commit(s) to origin", e); } } // Commit. commitReviewNote(reviewCommitHash, review); // Push. try { pushCommentsAndReviews(); } catch (Exception e) { throw new GitClientException("Error pushing, review is " + reviewCommitHash, e); } return reviewCommitHash; }
From source file:com.google.appraise.eclipse.core.client.git.AppraiseGitReviewClient.java
License:Open Source License
/** * Pushes the local comments and reviews back to the origin. *//* ww w . ja va2s . c o m*/ private void pushCommentsAndReviews() throws Exception { try (Git git = new Git(repo)) { RefSpec spec = new RefSpec(DEVTOOLS_PUSH_REFSPEC); PushCommand pushCommand = git.push(); pushCommand.setRefSpecs(spec); pushCommand.call(); } }
From source file:com.google.gerrit.acceptance.git.GitUtil.java
License:Apache License
public static PushResult pushHead(Git git, String ref, boolean pushTags) throws GitAPIException { PushCommand pushCmd = git.push(); pushCmd.setRefSpecs(new RefSpec("HEAD:" + ref)); if (pushTags) { pushCmd.setPushTags();/*w ww. jav a2 s .c o m*/ } Iterable<PushResult> r = pushCmd.call(); return Iterables.getOnlyElement(r); }
From source file:com.google.gerrit.acceptance.git.ssh.GitUtil.java
License:Apache License
public static PushResult pushHead(Git git, String ref) throws GitAPIException { PushCommand pushCmd = git.push(); pushCmd.setRefSpecs(new RefSpec("HEAD:" + ref)); Iterable<PushResult> r = pushCmd.call(); return Iterables.getOnlyElement(r); }
From source file:com.google.gerrit.acceptance.GitUtil.java
License:Apache License
public static PushResult pushHead(TestRepository<?> testRepo, String ref, boolean pushTags, boolean force) throws GitAPIException { PushCommand pushCmd = testRepo.git().push(); pushCmd.setForce(force);//from w w w .java 2s .co m pushCmd.setRefSpecs(new RefSpec("HEAD:" + ref)); if (pushTags) { pushCmd.setPushTags(); } Iterable<PushResult> r = pushCmd.call(); return Iterables.getOnlyElement(r); }