private static PushOperationResult push(
     Repository repository, RemoteConfig remoteConfig, boolean force, IProgressMonitor monitor)
     throws CoreException {
   try {
     if (remoteConfig == null) {
       throw new CoreException(
           createStatus(
               null,
               "Repository \"{0}\" has no remote repository configured",
               repository.toString()));
     }
     PushOperation op = createPushOperation(remoteConfig, repository, force);
     op.run(monitor);
     PushOperationResult pushResult = op.getOperationResult();
     if (hasFailedEntries(pushResult)) {
       throw new CoreException(
           EGitCoreActivator.createErrorStatus(
               NLS.bind(
                   "Could not push repository {0}: {1}",
                   repository.toString(), getErrors(pushResult)),
               null));
     }
     return pushResult;
   } catch (CoreException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(createStatus(e, "Could not push repo {0}", repository.toString()));
   }
 }
 private static String getCurrentBranch(Repository repository) throws CoreException {
   String branch = null;
   try {
     branch = repository.getBranch();
   } catch (IOException e) {
     throw new CoreException(
         createStatus(
             e, "Could not get current branch on repository \"{0}\"", repository.toString()));
   }
   return branch;
 }
  /**
   * Gets the UserConfig from the given repository. The UserConfig of a repo holds the default
   * author and committer.
   *
   * @param repository the repository
   * @return the user configuration
   * @throws CoreException
   * @see PersonIdent(Repository)
   * @see CommittHelper#calculateCommitInfo
   */
  private static UserConfig getUserConfig(Repository repository) throws CoreException {
    Assert.isLegal(repository != null, "Could not get user configuration. No repository provided.");

    if (repository.getConfig() == null) {
      throw new CoreException(
          createStatus(
              null,
              "no user configuration (author, committer) are present in repository \"{0}\"",
              repository.toString()));
    }
    return repository.getConfig().get(UserConfig.KEY);
  }
 /**
  * Returns all the remote configs from the given repository.
  *
  * @param repository the repository to retrieve the remote configs of
  * @return the remote configs that are available on the repository
  * @throws CoreException
  */
 public static List<RemoteConfig> getAllRemoteConfigs(Repository repository) throws CoreException {
   if (repository == null) {
     return Collections.emptyList();
   }
   try {
     return RemoteConfig.getAllRemoteConfigs(repository.getConfig());
   } catch (URISyntaxException e) {
     throw new CoreException(
         createStatus(
             e,
             "Could not get all remote repositories for repository \"{0}\"",
             repository.toString()));
   }
 }
 /**
  * Creates a push operation specification for the given push uris to the given push operation
  * specification.
  *
  * @param pushURIs the push uri's
  * @param pushRefSpecs the push ref specs
  * @param repository the repository
  * @return the push operation specification
  * @throws CoreException the core exception
  */
 private static PushOperationSpecification createPushSpec(
     Collection<URIish> pushURIs, Collection<RefSpec> pushRefSpecs, Repository repository)
     throws CoreException {
   try {
     PushOperationSpecification pushSpec = new PushOperationSpecification();
     for (URIish uri : pushURIs) {
       Collection<RemoteRefUpdate> remoteRefUpdates =
           Transport.open(repository, uri).findRemoteRefUpdatesFor(pushRefSpecs);
       pushSpec.addURIRefUpdates(uri, remoteRefUpdates);
     }
     return pushSpec;
   } catch (NotSupportedException e) {
     throw new CoreException(
         createStatus(
             e, "Could not connect repository \"{0}\" to a remote", repository.toString()));
   } catch (IOException e) {
     throw new CoreException(
         createStatus(
             e,
             "Could not convert remote specifications for repository \"{0}\" to a remote",
             repository.toString()));
   }
 }