示例#1
0
  boolean performClone() {
    final URIish uri = cloneSource.getSelection().getURI();
    setWindowTitle(NLS.bind(UIText.GitCloneWizard_jobName, uri.toString()));
    final boolean allSelected;
    final Collection<Ref> selectedBranches;
    if (validSource.isSourceRepoEmpty()) {
      // fetch all branches of empty repo
      allSelected = true;
      selectedBranches = Collections.emptyList();
    } else {
      allSelected = validSource.isAllSelected();
      selectedBranches = validSource.getSelectedBranches();
    }
    final File workdir = cloneDestination.getDestinationFile();
    final Ref ref = cloneDestination.getInitialBranch();
    final String remoteName = cloneDestination.getRemote();

    boolean created = workdir.exists();
    if (!created) created = workdir.mkdirs();

    if (!created || !workdir.isDirectory()) {
      final String errorMessage =
          NLS.bind(UIText.GitCloneWizard_errorCannotCreate, workdir.getPath());
      ErrorDialog.openError(
          getShell(),
          getWindowTitle(),
          UIText.GitCloneWizard_failed,
          new Status(IStatus.ERROR, Activator.getPluginId(), 0, errorMessage, null));
      // let's give user a chance to fix this minor problem
      return false;
    }

    int timeout =
        Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
    final CloneOperation op =
        new CloneOperation(
            uri,
            allSelected,
            selectedBranches,
            workdir,
            ref != null ? ref.getName() : null,
            remoteName,
            timeout);
    if (gerritConfiguration.configureGerrit()) doGerritConfiguration(remoteName, op);
    UserPasswordCredentials credentials = cloneSource.getCredentials();
    if (credentials != null)
      op.setCredentialsProvider(
          new UsernamePasswordCredentialsProvider(
              credentials.getUser(), credentials.getPassword()));

    alreadyClonedInto = workdir.getPath();

    cloneSource.saveUriInPrefs();
    if (!callerRunsCloneOperation) runAsJob(uri, op);
    else cloneOperation = op;
    return true;
  }
示例#2
0
 @Override
 public boolean performFinish() {
   try {
     if (cloneSource.getStoreInSecureStore()) {
       if (!SecureStoreUtils.storeCredentials(
           cloneSource.getCredentials(), cloneSource.getSelection().getURI())) return false;
     }
     return performClone();
   } finally {
     setWindowTitle(UIText.GitCloneWizard_title);
   }
 }
示例#3
0
  /** The default constructor */
  public GitCloneWizard() {
    setWindowTitle(UIText.GitCloneWizard_title);
    setDefaultPageImageDescriptor(UIIcons.WIZBAN_IMPORT_REPO);
    setNeedsProgressMonitor(true);
    cloneSource = new RepositorySelectionPage(true, null);
    cloneSource.setHelpContext(HELP_CONTEXT);
    validSource =
        new SourceBranchPage() {

          @Override
          public void setVisible(boolean visible) {
            if (visible) {
              setSelection(cloneSource.getSelection());
              setCredentials(cloneSource.getCredentials());
            }
            super.setVisible(visible);
          }
        };
    validSource.setHelpContext(HELP_CONTEXT);
    cloneDestination =
        new CloneDestinationPage() {
          @Override
          public void setVisible(boolean visible) {
            if (visible)
              setSelection(
                  cloneSource.getSelection(),
                  validSource.getAvailableBranches(),
                  validSource.getSelectedBranches(),
                  validSource.getHEAD());
            super.setVisible(visible);
          }
        };
    cloneDestination.setHelpContext(HELP_CONTEXT);
    gerritConfiguration =
        new GerritConfigurationPage() {

          @Override
          public void setVisible(boolean visible) {
            if (visible) setSelection(cloneSource.getSelection());
            super.setVisible(visible);
          }
        };
    gerritConfiguration.setHelpContext(HELP_CONTEXT);
  }