public static ArrayMemory valueOf(PushResult value) { ArrayMemory memory = valueOf((OperationResult) value); memory.refOfIndex("remoteUpdates").assign(valueOfRemoteRefUpdates(value.getRemoteUpdates())); return memory; }
ProgressMonitor.UNKNOWN); final PushResult res = new PushResult(); connection = transport.openPush(); try { res.setAdvertisedRefs(transport.getURI(), connection .getRefsMap()); res.peerUserAgent = connection.getPeerUserAgent(); res.setRemoteUpdates(toPush); monitor.endTask(); } finally { connection.close(); res.addMessages(connection.getMessages()); final TrackingRefUpdate tru = rru.getTrackingRefUpdate(); if (tru != null) res.add(tru);
protected RevCommit commitThenPush(Git git, String branch, CommitCommand commit) throws Exception { RevCommit answer = commit.call(); if (LOG.isDebugEnabled()) { LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage()); } if (isPushOnCommit()) { Iterable<PushResult> results = doPush(git); for (PushResult result : results) { if (LOG.isDebugEnabled()) { LOG.debug("Pushed " + result.getMessages() + " " + result.getURI() + " branch: " + branch + " updates: " + toString(result.getRemoteUpdates())); } } } return answer; }
private void printPushResult(final ObjectReader reader, final URIish uri, final PushResult result) throws IOException { shownURI = false; boolean everythingUpToDate = true; // at first, print up-to-date ones... for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { if (rru.getStatus() == Status.UP_TO_DATE) { if (verbose) printRefUpdateResult(reader, uri, result, rru); } else everythingUpToDate = false; } for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...then successful updates... if (rru.getStatus() == Status.OK) printRefUpdateResult(reader, uri, result, rru); } for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...finally, others (problematic) if (rru.getStatus() != Status.OK && rru.getStatus() != Status.UP_TO_DATE) printRefUpdateResult(reader, uri, result, rru); } AbstractFetchCommand.showRemoteMessages(errw, result.getMessages()); if (everythingUpToDate) outw.println(CLIText.get().everythingUpToDate); }
public void logPushResult(Iterable<PushResult> results, Repository repository, boolean verbose) throws IOException { String local = repository.getDirectory().getCanonicalPath(); for (PushResult result : results) { Map<String, RemoteRefUpdate> map = new TreeMap<>(); for (RemoteRefUpdate update : result.getRemoteUpdates()) { if (verbose || update.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE) { map.put(update.getSrcRef(), update); } } if (map.size() > 0) { LOG.info(String.format("Pushed from %s to %s:", local, result.getURI())); for (RemoteRefUpdate update : map.values()) { LOG.info(String.format(" - %s (%s)", update.getSrcRef(), update.getStatus())); } } else { LOG.info(String.format("Pushed from %s to %s - no reference was updated", local, result.getURI())); } } }
Iterable<PushResult> results = command.call(); for (PushResult pushResult : results) { Collection<RemoteRefUpdate> resultsCollection = pushResult.getRemoteUpdates(); Map<PushResult,RemoteRefUpdate> resultsMap = new HashMap<>(); for(RemoteRefUpdate remoteRefUpdate : resultsCollection) RemoteRefUpdate remoteUpdate = pushResult.getRemoteUpdate(destinationBranch); if (remoteUpdate != null) { org.eclipse.jgit.transport.RemoteRefUpdate.Status status =
private String getResult(RefUpdateElement element) { StringBuilder result = new StringBuilder(EMPTY_STRING); PushOperationResult pushOperationResult = element .getPushOperationResult(); final URIish uri = element.getUri(); result.append(UIText.PushResultTable_repository); result.append(SPACE); result.append(uri.toString()); result.append(Text.DELIMITER); result.append(Text.DELIMITER); String message = element.getRemoteRefUpdate().getMessage(); if (message != null) result.append(message).append(Text.DELIMITER); StringBuilder messagesBuffer = new StringBuilder(pushOperationResult .getPushResult(uri).getMessages()); trim(messagesBuffer); if (messagesBuffer.length() > 0) result.append(messagesBuffer).append(Text.DELIMITER); trim(result); return result.toString(); }
@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(); } } }
/** * @inheritDoc */ @Override public Iterable<PushResult> push(Git git, String username, String password, String reference, String remote, boolean force) { UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); try { Iterable<PushResult> results = git .push() .setCredentialsProvider(credentialsProvider) .add(reference) .setRemote(remote) .setForce(force) .call(); for(PushResult result : results){ RemoteRefUpdate update = result.getRemoteUpdate(reference); RemoteRefUpdate.Status status = update.getStatus(); if(!(status.equals(RemoteRefUpdate.Status.OK)||status.equals(RemoteRefUpdate.Status.UP_TO_DATE))){ throw new RuntimeException("Failed to push changes to origin"); } } return results; } catch (GitAPIException e) { throw new RuntimeException("Failed to push to origin", e); } }
protected RevCommit commitThenPush(Git git, CommitCommand commit) throws Exception { RevCommit answer = commit.call(); if (LOG.isDebugEnabled()) { LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage()); } if (isPushOnCommit()) { Iterable<PushResult> results = doPush(git); for (PushResult result : results) { if (LOG.isDebugEnabled()) { LOG.debug("Pushed " + result.getMessages() + " " + result.getURI() + " branch: " + branch + " updates: " + toString(result.getRemoteUpdates())); } } } return answer; }
for (PushResult pr : i) reporter.infoText(getCommandName(), "messages: '" + pr.getMessages() + "'"); if(null != pr && null != pr.getRemoteUpdates() && !pr.getRemoteUpdates().isEmpty()) { for (RemoteRefUpdate update : pr.getRemoteUpdates()) { if (pr.getMessages() != null && pr.getMessages().length() > 0) { throw new JGitFlowGitAPIException("error pushing to " + branchToPush + " - status: " + trackingStatus.name() + " - " + pr.getMessages()); } else { throw new JGitFlowGitAPIException("error pushing to " + branchToPush + " - " + trackingStatus.name()); throw new JGitFlowGitAPIException("error pushing to " + branchToPush + " - " + pr.getMessages());
@Override public void logPushResult(Iterable<PushResult> results, Repository repository, boolean verbose) throws IOException { String local = repository.getDirectory().getCanonicalPath(); for (PushResult result : results) { Map<String, RemoteRefUpdate> map = new TreeMap<>(); for (RemoteRefUpdate update : result.getRemoteUpdates()) { if (verbose || update.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE) { map.put(update.getSrcRef(), update); } } if (map.size() > 0) { Activator.log(LogService.LOG_INFO, String.format("Pushed from %s to %s:", local, result.getURI())); for (RemoteRefUpdate update : map.values()) { Activator.log(LogService.LOG_INFO, String.format(" - %s (%s)", update.getSrcRef(), update.getStatus())); } } else { Activator.log(LogService.LOG_INFO, String.format("Pushed from %s to %s - no reference was updated", local, result.getURI())); } } }
final Iterable<PushResult> pushResults = pushCommand.call(); for (PushResult pushResult : pushResults) { logger.debug(pushResult.getMessages());
/** * Use with care! */ public boolean deleteBranch() { if (!branch.startsWith("feature/")) { throw new GitException("Can only delete feature branch."); } try { final Git git = gitOpen(); git.checkout().setCreateBranch(true).setName("feature/temp_" + UUID.randomUUID()).call(); List<String> deletedBranches = git.branchDelete().setBranchNames(branch).setForce(true).call(); if (deletedBranches.size() == 1) { // delete branch 'branchToDelete' on remote 'origin' RefSpec refSpec = new RefSpec().setSource(null).setDestination("refs/heads/" + branch); Iterable<PushResult> results = git.push().setCredentialsProvider(credentialsProvider()).setRefSpecs(refSpec).setRemote("origin").call(); for (PushResult result : results) { RemoteRefUpdate myUpdate = result.getRemoteUpdate("refs/heads/" + branch); if (myUpdate.isDelete() && myUpdate.getStatus() == RemoteRefUpdate.Status.OK) { return true; } } } return false; } catch (IOException | GitAPIException e) { throw new GitException("Delete branch failed", e); } }
private boolean allCommitsArePushedWithSuccess(Iterable<PushResult> forcePushResult) { long nbCommitsWithNotOkStatus = StreamSupport.stream(forcePushResult.spliterator(), false) .flatMap(pushResult -> pushResult.getRemoteUpdates().stream()) .filter(result -> result.getStatus() != RemoteRefUpdate.Status.OK) .count(); return (nbCommitsWithNotOkStatus == 0); }
public static RevCommit doCommitAndPush(Git git, String message, UserDetails userDetails, PersonIdent author, String branch, String origin, boolean pushOnCommit) throws GitAPIException { CommitCommand commit = git.commit().setAll(true).setMessage(message); if (author != null) { commit = commit.setAuthor(author); } RevCommit answer = commit.call(); if (LOG.isDebugEnabled()) { LOG.debug("Committed " + answer.getId() + " " + answer.getFullMessage()); } if (pushOnCommit) { PushCommand push = git.push(); configureCommand(push, userDetails); Iterable<PushResult> results = push.setRemote(origin).call(); for (PushResult result : results) { if (LOG.isDebugEnabled()) { LOG.debug("Pushed " + result.getMessages() + " " + result.getURI() + " branch: " + branch + " updates: " + toString(result.getRemoteUpdates())); } } } return answer; }
for (PushResult pr : i) reporter.infoText(getCommandName(), "messages: '" + pr.getMessages() + "'"); for(RemoteRefUpdate update : pr.getRemoteUpdates()) { if (update.hasTrackingRefUpdate()) { RefUpdate.Result trackingResult = update.getTrackingRefUpdate().getResult(); if (failedResult(trackingResult)) { if (pr.getMessages() != null && pr.getMessages().length() > 0) { throw new JGitFlowGitAPIException("error pushing to " + branchToPush + " - status: " + trackingResult.name() + " - " + pr.getMessages()); } else { throw new JGitFlowGitAPIException("error pushing to " + branchToPush + " - " + trackingResult.name());
@Override public void logPushResult(Iterable<PushResult> results, Repository repository, boolean verbose) throws IOException { String local = repository.getDirectory().getCanonicalPath(); for (PushResult result : results) { Map<String, RemoteRefUpdate> map = new TreeMap<>(); for (RemoteRefUpdate update : result.getRemoteUpdates()) { if (verbose || update.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE) { map.put(update.getSrcRef(), update); } } if (map.size() > 0) { Activator.log(LogService.LOG_INFO, String.format("Pushed from %s to %s:", local, result.getURI())); for (RemoteRefUpdate update : map.values()) { Activator.log(LogService.LOG_INFO, String.format(" - %s (%s)", update.getSrcRef(), update.getStatus())); } } else { Activator.log(LogService.LOG_INFO, String.format("Pushed from %s to %s - no reference was updated", local, result.getURI())); } } }
+ pushResult.getMessages());
ProgressMonitor.UNKNOWN); final PushResult res = new PushResult(); connection = transport.openPush(); try { res.setAdvertisedRefs(transport.getURI(), connection .getRefsMap()); res.peerUserAgent = connection.getPeerUserAgent(); res.setRemoteUpdates(toPush); monitor.endTask(); } finally { connection.close(); res.addMessages(connection.getMessages()); final TrackingRefUpdate tru = rru.getTrackingRefUpdate(); if (tru != null) res.add(tru);