forked from qt-creator/qt-creator
CheckoutWizards: Use IVersionControl::createInitialCheckoutCommand
Change-Id: I09dd38f66b9cad46d561493c2e27a833595d8728 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -48,17 +48,11 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(Constants::VCS_ID_GIT, parent)
|
||||
{
|
||||
setTitle(tr("Cloning"));
|
||||
setStartedStatus(tr("Cloning started..."));
|
||||
|
||||
const Internal::GitVersionControl *vc = Internal::GitPlugin::instance()->gitVersionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto cwp = new CloneWizardPage;
|
||||
cwp->setPath(path.toString());
|
||||
addPage(cwp);
|
||||
@@ -69,7 +63,22 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
// Collect parameters for the clone command.
|
||||
const CloneWizardPage *cwp = find<CloneWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
return cwp->createCheckoutJob(checkoutDir);
|
||||
|
||||
const QString baseDirectory = cwp->path();
|
||||
const QString subDirectory = cwp->directory();
|
||||
|
||||
*checkoutDir = Utils::FileName::fromString(baseDirectory + QLatin1Char('/') + subDirectory);
|
||||
|
||||
const QString checkoutBranch = cwp->branch();
|
||||
|
||||
QStringList args;
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
if (cwp->isRecursive())
|
||||
args << QLatin1String("--recursive");
|
||||
|
||||
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(baseDirectory),
|
||||
subDirectory, args);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -108,27 +108,6 @@ QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const
|
||||
return url;
|
||||
}
|
||||
|
||||
VcsCommand *CloneWizardPage::createCheckoutJob(Utils::FileName *checkoutPath) const
|
||||
{
|
||||
const Internal::GitClient *client = Internal::GitPlugin::instance()->client();
|
||||
const QString workingDirectory = path();
|
||||
const QString checkoutDir = directory();
|
||||
*checkoutPath = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + checkoutDir);
|
||||
|
||||
const QString checkoutBranch = branch();
|
||||
|
||||
QStringList args(QLatin1String("clone"));
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
if (d->recursiveCheckBox->isChecked())
|
||||
args << QLatin1String("--recursive");
|
||||
args << QLatin1String("--progress") << repository() << checkoutDir;
|
||||
auto command = new VcsCommand(workingDirectory, client->processEnvironment());
|
||||
command->addFlags(VcsCommand::MergeOutputChannels);
|
||||
command->addJob(client->vcsBinary(), args, -1);
|
||||
return command;
|
||||
}
|
||||
|
||||
QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
{
|
||||
// Run git on remote repository if an URL was specified.
|
||||
@@ -142,6 +121,11 @@ QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
return branches;
|
||||
}
|
||||
|
||||
bool CloneWizardPage::isRecursive() const
|
||||
{
|
||||
return d->recursiveCheckBox->isChecked();
|
||||
}
|
||||
|
||||
} // namespace Git
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
explicit CloneWizardPage(QWidget *parent = 0);
|
||||
~CloneWizardPage();
|
||||
|
||||
VcsBase::VcsCommand *createCheckoutJob(Utils::FileName *checkoutPath) const;
|
||||
QStringList branches(const QString &repository, int *current) override;
|
||||
bool isRecursive() const;
|
||||
|
||||
protected:
|
||||
QString directoryFromRepository(const QString &r) const override;
|
||||
QStringList branches(const QString &repository, int *current) override;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user