Beispiel #1
0
  private void pushUpstream(final RevCommit commit) {
    RemoteConfig config = SimpleConfigurePushDialog.getConfiguredRemote(repository);
    if (config == null) {
      final Display display = Display.getDefault();
      display.asyncExec(
          new Runnable() {

            public void run() {
              try {
                PushBranchWizard pushWizard = null;
                String fullBranch = repository.getFullBranch();
                if (fullBranch != null && fullBranch.startsWith(Constants.R_HEADS)) {
                  Ref ref = repository.getRef(fullBranch);
                  pushWizard = new PushBranchWizard(repository, ref);
                } else {
                  pushWizard = new PushBranchWizard(repository, commit.getId());
                }
                WizardDialog wizardDialog = new WizardDialog(display.getActiveShell(), pushWizard);
                wizardDialog.setHelpAvailable(true);
                wizardDialog.open();
              } catch (IOException e) {
                Activator.handleError(NLS.bind(UIText.CommitUI_pushFailedMessage, e), e, true);
              }
            }
          });
    } else {
      PushOperationUI op = new PushOperationUI(repository, config.getName(), false);
      op.start();
    }
  }
  private void testFetchFromOrigin(boolean useRemote) throws Exception {

    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile);
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile2);

    Repository repository = lookupRepository(clonedRepositoryFile2);
    // add the configuration for push from cloned2
    repository.getConfig().setString("remote", "origin", "push", "refs/heads/*:refs/heads/*");
    repository.getConfig().save();

    SWTBotTree tree = getOrOpenView().bot().tree();

    String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin";
    String dialogTitle = NLS.bind(UIText.FetchResultDialog_title, destinationString);

    selectNode(tree, useRemote, true);
    runFetch(tree);

    SWTBotShell confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
    confirm.close();

    deleteAllProjects();
    shareProjects(clonedRepositoryFile2);
    String objid = repository.getRef("refs/heads/master").getTarget().getObjectId().name();
    objid = objid.substring(0, 7);
    touchAndSubmit(null);
    // push from other repository
    PushOperationUI op = new PushOperationUI(repository, "origin", false);
    op.start();

    String pushdialogTitle = NLS.bind(UIText.PushResultDialog_title, op.getDestinationString());

    bot.shell(pushdialogTitle).close();

    deleteAllProjects();

    refreshAndWait();

    selectNode(tree, useRemote, true);
    runFetch(tree);

    confirm = bot.shell(dialogTitle);
    SWTBotTreeItem[] treeItems = confirm.bot().tree().getAllItems();
    boolean found = false;
    for (SWTBotTreeItem item : treeItems) {
      found = item.getText().contains(objid);
      if (found) break;
    }
    assertTrue(found);
    confirm.close();

    selectNode(tree, useRemote, true);
    runFetch(tree);

    confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
  }