private void modifyUpdatesForDryRun() { for (RemoteRefUpdate rru : toPush.values()) if (rru.getStatus() == Status.NOT_ATTEMPTED) rru.setStatus(Status.OK); }
private Map<String, RemoteRefUpdate> rejectAll() { for (RemoteRefUpdate rru : toPush.values()) { if (rru.getStatus() == Status.NOT_ATTEMPTED) { rru.setStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON); rru.setMessage(JGitText.get().transactionAborted); } } return Collections.emptyMap(); }
private void updateTrackingRefs() { for (RemoteRefUpdate rru : toPush.values()) { final Status status = rru.getStatus(); if (rru.hasTrackingRefUpdate() && (status == Status.UP_TO_DATE || status == Status.OK)) { // update local tracking branch only when there is a chance that // it has changed; this is possible for: // -updated (OK) status, // -up to date (UP_TO_DATE) status try { rru.updateTrackingRef(walker); } catch (IOException e) { // ignore as RefUpdate has stored I/O error status } } } }
if (rru.getStatus() == Status.AWAITING_REPORT) throw new PackProtocolException(MessageFormat.format( JGitText.get().expectedReportForRefNotReceived , uri, rru.getRemoteName()));
Status getStatus() { return update.getStatus(); }
private void modifyUpdatesForDryRun() { for (final RemoteRefUpdate rru : toPush.values()) if (rru.getStatus() == Status.NOT_ATTEMPTED) rru.setStatus(Status.OK); }
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); }
private void modifyUpdatesForDryRun() { for (RemoteRefUpdate rru : toPush.values()) if (rru.getStatus() == Status.NOT_ATTEMPTED) rru.setStatus(Status.OK); }
/** * Inspect the push returns to know if the push command has succeeded. * * @param call The push results object. * @return Returns <code>true</code> pushed, <code>false</code> otherwise. */ private static boolean isPushed(Iterable<PushResult> call) { for (PushResult pr : call) { Optional<RemoteRefUpdate> any = pr.getRemoteUpdates().stream() .filter(ru -> !(RemoteRefUpdate.Status.OK.equals(ru.getStatus()) || RemoteRefUpdate.Status.UP_TO_DATE.equals(ru.getStatus()))).findAny(); if (any.isPresent()) { return false; } } return true; }
private void logPushResultDetails(Iterable<PushResult> forcePushResult) { if (log.isInfoEnabled()) { StringBuilder sb = new StringBuilder("force push results : \n"); for (PushResult pushResult : forcePushResult) { Collection<RemoteRefUpdate> pushResultDetails = pushResult.getRemoteUpdates(); for (RemoteRefUpdate result : pushResultDetails) { sb.append("- ").append(result.getRemoteName()) .append(" - ").append(result.getStatus().name()) .append(" - ").append(result.getNewObjectId()); } } log.info(sb.toString()); } }
private Map<String, RemoteRefUpdate> rejectAll() { for (RemoteRefUpdate rru : toPush.values()) { if (rru.getStatus() == Status.NOT_ATTEMPTED) { rru.setStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON); rru.setMessage(JGitText.get().transactionAborted); } } return Collections.emptyMap(); }
private Map<String, RemoteRefUpdate> rejectAll() { for (RemoteRefUpdate rru : toPush.values()) { if (rru.getStatus() == Status.NOT_ATTEMPTED) { rru.setStatus(RemoteRefUpdate.Status.REJECTED_OTHER_REASON); rru.setMessage(JGitText.get().transactionAborted); } } return Collections.emptyMap(); }
private void updateTrackingRefs() { for (RemoteRefUpdate rru : toPush.values()) { final Status status = rru.getStatus(); if (rru.hasTrackingRefUpdate() && (status == Status.UP_TO_DATE || status == Status.OK)) { // update local tracking branch only when there is a chance that // it has changed; this is possible for: // -updated (OK) status, // -up to date (UP_TO_DATE) status try { rru.updateTrackingRef(walker); } catch (IOException e) { // ignore as RefUpdate has stored I/O error status } } } }
private void updateTrackingRefs() { for (final RemoteRefUpdate rru : toPush.values()) { final Status status = rru.getStatus(); if (rru.hasTrackingRefUpdate() && (status == Status.UP_TO_DATE || status == Status.OK)) { // update local tracking branch only when there is a chance that // it has changed; this is possible for: // -updated (OK) status, // -up to date (UP_TO_DATE) status try { rru.updateTrackingRef(walker); } catch (IOException e) { // ignore as RefUpdate has stored I/O error status } } } }
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())); } } }
@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())); } } }
@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())); } } }
public Object[] getChildren(Object object) { if (children != null) return children; switch (update.getStatus()) { case OK: if (!isDelete()) { final Ref ref = getAdvertisedRemoteRef(); if (ref != null) { children = getCommits(ref); break; } } //$FALL-THROUGH$ default: children = super.getChildren(object); } return children; }
public static Iterable<PushResult> push( ScmLogger logger, Git git, GitScmProviderRepository repo, RefSpec refSpec ) throws GitAPIException, InvalidRemoteException, TransportException { CredentialsProvider credentials = JGitUtils.prepareSession( logger, git, repo ); Iterable<PushResult> pushResultList = git.push().setCredentialsProvider( credentials ).setRefSpecs( refSpec ).call(); for ( PushResult pushResult : pushResultList ) { Collection<RemoteRefUpdate> ru = pushResult.getRemoteUpdates(); for ( RemoteRefUpdate remoteRefUpdate : ru ) { logger.info( remoteRefUpdate.getStatus() + " - " + remoteRefUpdate.toString() ); } } return pushResultList; }
public static Iterable<PushResult> push( ScmLogger logger, Git git, GitScmProviderRepository repo, RefSpec refSpec ) throws GitAPIException, InvalidRemoteException, TransportException { CredentialsProvider credentials = JGitUtils.prepareSession( logger, git, repo ); PushCommand command = git.push().setRefSpecs(refSpec).setCredentialsProvider(credentials) .setTransportConfigCallback(new JGitTransportConfigCallback(repo, logger)); Iterable<PushResult> pushResultList = command.call(); for ( PushResult pushResult : pushResultList ) { Collection<RemoteRefUpdate> ru = pushResult.getRemoteUpdates(); for ( RemoteRefUpdate remoteRefUpdate : ru ) { logger.info( remoteRefUpdate.getStatus() + " - " + remoteRefUpdate.toString() ); } } return pushResultList; }