Examples of PushOperation


Examples of org.eclipse.egit.core.op.PushOperation

      if (!SecureStoreUtils.storeCredentials(repoPage
          .getCredentials(), repoPage.getSelection().getURI()))
        return false;
    }

    final PushOperation operation = createPushOperation(calledFromRepoPage);
    if (operation == null)
      return false;
    UserPasswordCredentials credentials = repoPage.getCredentials();
    if (credentials != null)
      operation.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
          credentials.getUser(), credentials.getPassword()));
    final PushOperationResult resultToCompare;
    if (confirmPage.isShowOnlyIfChangedSelected())
      resultToCompare = confirmPage.getConfirmedResult();
    else
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

          spec.addURIRefUpdates(uri, ConfirmationPage
              .copyUpdates(updates));
      }
      int timeout = Activator.getDefault().getPreferenceStore().getInt(
          UIPreferences.REMOTE_CONNECTION_TIMEOUT);
      return new PushOperation(localDb, spec, false, timeout);
    } catch (final IOException e) {
      ErrorDialog.openError(getShell(),
          UIText.PushWizard_cantPrepareUpdatesTitle,
          UIText.PushWizard_cantPrepareUpdatesMessage, new Status(
              IStatus.ERROR, Activator.getPluginId(), e
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

    if (displayedRepoSelection.isConfigSelected())
      fetchSpecs = displayedRepoSelection.getConfig().getFetchRefSpecs();
    else
      fetchSpecs = null;

    final PushOperation operation;
    try {
      final Collection<RemoteRefUpdate> updates = Transport
          .findRemoteRefUpdatesFor(local, displayedRefSpecs,
              fetchSpecs);
      if (updates.isEmpty()) {
        // It can happen only when local refs changed in the mean time.
        setErrorMessage(UIText.ConfirmationPage_errorRefsChangedNoMatch);
        setPageComplete(false);
        return;
      }

      final PushOperationSpecification spec = new PushOperationSpecification();
      for (final URIish uri : displayedRepoSelection.getPushURIs())
        spec.addURIRefUpdates(uri, copyUpdates(updates));
      int timeout = Activator.getDefault().getPreferenceStore().getInt(
          UIPreferences.REMOTE_CONNECTION_TIMEOUT);
      operation = new PushOperation(local, spec, true, timeout);
      if (credentials != null)
        operation.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
            credentials.getUser(), credentials.getPassword()));
      getContainer().run(true, true, new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor)
            throws InvocationTargetException, InterruptedException {
          operation.run(monitor);
        }
      });
    } catch (final IOException e) {
      setErrorMessage(NLS.bind(
          UIText.ConfirmationPage_errorCantResolveSpecs, e
              .getMessage()));
      return;
    } catch (final InvocationTargetException e) {
      setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorUnexpected, e
          .getCause().getMessage()));
      return;
    } catch (final InterruptedException e) {
      setErrorMessage(UIText.ConfirmationPage_errorInterrupted);
      setPageComplete(true);
      displayedRefSpecs = null;
      displayedRepoSelection = null;
      return;
    }

    final PushOperationResult result = operation.getOperationResult();
    resultPanel.setData(local, result);
    if (result.isSuccessfulConnectionForAnyURI()) {
      setPageComplete(true);
      confirmedResult = result;
    } else {
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

  }


  private void createPushOperation() throws CoreException {
    if (remoteName != null) {
      op = new PushOperation(repository, remoteName, dryRun, getTimeout());
      return;
    }

    if (spec == null) {
      // spec == null => config was supplied in constructor
      // we don't use the configuration directly, as it may contain
      // unsaved changes and as we may need
      // to add the default push RefSpec here
      spec = new PushOperationSpecification();

      List<URIish> urisToPush = new ArrayList<URIish>();
      for (URIish uri : config.getPushURIs())
        urisToPush.add(uri);
      if (urisToPush.isEmpty() && !config.getURIs().isEmpty())
        urisToPush.add(config.getURIs().get(0));

      List<RefSpec> pushRefSpecs = new ArrayList<RefSpec>();
      pushRefSpecs.addAll(config.getPushRefSpecs());

      for (URIish uri : urisToPush) {
        try {
          // Fetch ref specs are passed here to make sure that the
          // returned remote ref updates include tracking branch
          // updates.
          Collection<RemoteRefUpdate> remoteRefUpdates = Transport
              .findRemoteRefUpdatesFor(repository, pushRefSpecs,
                  config.getFetchRefSpecs());
          spec.addURIRefUpdates(uri, remoteRefUpdates);
        } catch (NotSupportedException e) {
          throw new CoreException(Activator.createErrorStatus(
              e.getMessage(), e));
        } catch (IOException e) {
          throw new CoreException(Activator.createErrorStatus(
              e.getMessage(), e));
        }
      }
    }
    op = new PushOperation(repository, spec, dryRun, getTimeout());
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

   */
  @Test
  public void testPush() throws Exception {

    // push from repository1 to repository2
    PushOperation pop = createPushOperation();
    pop.run(new NullProgressMonitor());
    assertEquals(Status.UP_TO_DATE, getStatus(pop.getOperationResult()));

    // let's add a new file to the project shared with repository1
    IProject proj = importProject(repository1, projectName);
    ArrayList<IFile> files = new ArrayList<IFile>();
    IFile newFile = testUtils.addFileToProject(proj, "folder2/file2.txt",
        "New file");
    files.add(newFile);
    IFile[] fileArr = files.toArray(new IFile[files.size()]);

    AddToIndexOperation trop = new AddToIndexOperation(files);
    trop.execute(null);
    CommitOperation cop = new CommitOperation(fileArr, files, TestUtils.AUTHOR,
        TestUtils.COMMITTER, "Added file");
    cop.execute(null);

    proj.delete(false, false, null);

    pop = createPushOperation();
    pop.run(null);
    assertEquals(Status.OK, getStatus(pop.getOperationResult()));

    try {
      // assert that we cannot run this again
      pop.run(null);
      fail("Expected Exception not thrown");
    } catch (IllegalStateException e) {
      // expected
    }

    pop = createPushOperation();
    pop.run(null);
    assertEquals(Status.UP_TO_DATE, getStatus(pop.getOperationResult()));

    String newFilePath = newFile.getFullPath().toOSString();

    File testFile = new File(workdir2, newFilePath);
    assertFalse(testFile.exists());
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

  public void testInvalidUriDuringPush() throws Exception {
    ILog log = Activator.getDefault().getLog();
    LogListener listener = new LogListener();
    log.addLogListener(listener);

    PushOperation pop = createInvalidPushOperation();
    pop.run(new NullProgressMonitor());
    PushOperationResult result = pop.getOperationResult();
    String errorMessage = result.getErrorMessage(new URIish(INVALID_URI));
    assertNotNull(errorMessage);
    assertTrue(errorMessage.contains(INVALID_URI));

    assertTrue(listener.loggedSomething());
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

    Repository local = repository1.getRepository();
    RemoteRefUpdate update = new RemoteRefUpdate(local, "HEAD", "refs/heads/test",
        false, null, null);
    spec.addURIRefUpdates(remote, Collections.singletonList(update));
    // now we can construct the push operation
    PushOperation pop = new PushOperation(local, spec, false, 0);
    return pop;
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

   */
  @Test
  public void testIllegalStateExceptionOnGetResultWithoutRun()
      throws Exception {
    // push from repository1 to repository2
    PushOperation pop = createPushOperation();
    try {
      pop.getOperationResult();
      fail("Expected Exception not thrown");
    } catch (IllegalStateException e) {
      // expected
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

    RemoteRefUpdate update = new RemoteRefUpdate(repository1
        .getRepository(), "HEAD", "refs/heads/test", false, null, null);
    refUpdates.add(update);
    spec.addURIRefUpdates(remote, refUpdates);

    PushOperation pop = new PushOperation(repository1.getRepository(),
        spec, false, 0);
    pop.run(null);

    pop = new PushOperation(repository1.getRepository(), spec, false, 0);
    try {
      pop.run(null);
      fail("Expected Exception not thrown");
    } catch (IllegalStateException e) {
      // expected
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.PushOperation

        repository2.getRepository(), "HEAD", "refs/heads/master", false,
        trackingRef, null);
    PushOperationSpecification spec = new PushOperationSpecification();
    spec.addURIRefUpdates(remote, Arrays.asList(update));

    PushOperation push = new PushOperation(repository2.getRepository(),
        spec, false, 0);
    push.run(null);

    PushOperationResult result = push.getOperationResult();
    PushResult pushResult = result.getPushResult(remote);
    assertNotNull("Expected result to have tracking ref update", pushResult.getTrackingRefUpdate(trackingRef));

    ObjectId trackingId = repository2.getRepository().resolve(trackingRef);
    assertEquals("Expected tracking branch to be updated", commit.getId(), trackingId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.