List of usage examples for org.eclipse.jgit.transport RemoteRefUpdate toString
@SuppressWarnings("nls") @Override public String toString()
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()); }/* ww w . j a v a 2 s.c o m*/ } }
From source file:com.verigreen.jgit.JGitOperator.java
License:Apache License
@Override public boolean push(String sourceBranch, String destinationBranch) { PushCommand command = _git.push();//ww w .jav a2 s.co m boolean ret = true; RefSpec refSpec = new RefSpec().setSourceDestination(sourceBranch, destinationBranch); command.setRefSpecs(refSpec); try { List<Ref> remoteBranches = _git.branchList().setListMode(ListMode.REMOTE).call(); Iterable<PushResult> results = command.call(); for (PushResult pushResult : results) { Collection<RemoteRefUpdate> resultsCollection = pushResult.getRemoteUpdates(); Map<PushResult, RemoteRefUpdate> resultsMap = new HashMap<>(); for (RemoteRefUpdate remoteRefUpdate : resultsCollection) { resultsMap.put(pushResult, remoteRefUpdate); } RemoteRefUpdate remoteUpdate = pushResult.getRemoteUpdate(destinationBranch); if (remoteUpdate != null) { org.eclipse.jgit.transport.RemoteRefUpdate.Status status = remoteUpdate.getStatus(); ret = status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK) || status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.UP_TO_DATE); } if (remoteUpdate == null && !remoteBranches.toString().contains(destinationBranch)) { for (RemoteRefUpdate resultValue : resultsMap.values()) { if (resultValue.toString().contains("REJECTED_OTHER_REASON")) { ret = false; } } } } } catch (Throwable e) { throw new RuntimeException( String.format("Failed to push [%s] into [%s]", sourceBranch, destinationBranch), e); } return ret; }
From source file:org.apache.maven.scm.provider.git.jgit.command.JGitUtils.java
License:Apache License
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();//from w w w . j a v a2 s . c om for (PushResult pushResult : pushResultList) { Collection<RemoteRefUpdate> ru = pushResult.getRemoteUpdates(); for (RemoteRefUpdate remoteRefUpdate : ru) { logger.info(remoteRefUpdate.getStatus() + " - " + remoteRefUpdate.toString()); } } return pushResultList; }