diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-05-12 16:12:48 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-05-18 13:43:39 +0000 |
commit | 3d0b690d315e4006caf505a91143b75f492b6ecc (patch) | |
tree | a949a59dd657684d5580d0522598329f047771df /src/plugins/git | |
parent | bf249dc66094ff71a4d2f65b7504d0f5048af809 (diff) |
Git: Replace CloneWizard with a Json wizard
Change-Id: I2188c083665acc239bc98bf857ff57b071805fbc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/clonewizard.cpp | 85 | ||||
-rw-r--r-- | src/plugins/git/clonewizard.h | 54 | ||||
-rw-r--r-- | src/plugins/git/clonewizardpage.cpp | 141 | ||||
-rw-r--r-- | src/plugins/git/clonewizardpage.h | 67 | ||||
-rw-r--r-- | src/plugins/git/git.pro | 4 | ||||
-rw-r--r-- | src/plugins/git/git.qbs | 4 | ||||
-rw-r--r-- | src/plugins/git/git.qrc | 1 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 33 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.h | 2 | ||||
-rw-r--r-- | src/plugins/git/images/git.png | bin | 466 -> 0 bytes |
10 files changed, 0 insertions, 391 deletions
diff --git a/src/plugins/git/clonewizard.cpp b/src/plugins/git/clonewizard.cpp deleted file mode 100644 index 4e2cfcb53ec..00000000000 --- a/src/plugins/git/clonewizard.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizard.h" -#include "clonewizardpage.h" - -#include "gitplugin.h" -#include "gitversioncontrol.h" - -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> -#include <utils/qtcassert.h> - -using namespace VcsBase; - -namespace Git { -namespace Internal { - -// -------------------------------------------------------------------- -// CloneWizard: -// -------------------------------------------------------------------- - -CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : - BaseCheckoutWizard(Constants::VCS_ID_GIT, parent) -{ - setTitle(tr("Cloning")); - setStartedStatus(tr("Cloning started...")); - - auto cwp = new CloneWizardPage; - cwp->setPath(path.toString()); - addPage(cwp); -} - -VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) -{ - // Collect parameters for the clone command. - const CloneWizardPage *cwp = find<CloneWizardPage>(); - QTC_ASSERT(cwp, return 0); - - 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 -} // namespace Git diff --git a/src/plugins/git/clonewizard.h b/src/plugins/git/clonewizard.h deleted file mode 100644 index 72a00704b70..00000000000 --- a/src/plugins/git/clonewizard.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARD_H -#define CLONEWIZARD_H - -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> - -namespace Git { -namespace Internal { - -class CloneWizard : public VcsBase::BaseCheckoutWizard -{ - Q_OBJECT - -public: - CloneWizard(const Utils::FileName &path, QWidget *parent = 0); - -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir) override; -}; - -} // namespace Internal -} // namespace Git - -#endif // CLONEWIZARD_H diff --git a/src/plugins/git/clonewizardpage.cpp b/src/plugins/git/clonewizardpage.cpp deleted file mode 100644 index feb936593b2..00000000000 --- a/src/plugins/git/clonewizardpage.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizardpage.h" -#include "gitplugin.h" -#include "gitclient.h" - -#include <vcsbase/vcscommand.h> - -#include <QCheckBox> - -using namespace VcsBase; - -namespace Git { - -struct CloneWizardPagePrivate -{ - CloneWizardPagePrivate(); - - bool urlIsLocal(const QString &url); - - const QString mainLinePostfix; - const QString gitPostFix; - QCheckBox *recursiveCheckBox; -}; - -CloneWizardPagePrivate::CloneWizardPagePrivate() : - mainLinePostfix(QLatin1String("/mainline.git")), - gitPostFix(QLatin1String(".git")), - recursiveCheckBox(0) -{ -} - -bool CloneWizardPagePrivate::urlIsLocal(const QString &url) -{ - if (url.startsWith(QLatin1String("file://")) - || url.startsWith(QLatin1Char('/')) - || (url.at(0).isLetter() && url.at(1) == QLatin1Char(':') && url.at(2) == QLatin1Char('\\'))) - return true; - return false; -} - -CloneWizardPage::CloneWizardPage(QWidget *parent) : - BaseCheckoutWizardPage(parent), - d(new CloneWizardPagePrivate) -{ - setTitle(tr("Location")); - setSubTitle(tr("Specify repository URL, checkout directory and path.")); - setRepositoryLabel(tr("Clone URL:")); - d->recursiveCheckBox = new QCheckBox(tr("Recursive")); - addLocalControl(d->recursiveCheckBox); -} - -CloneWizardPage::~CloneWizardPage() -{ - delete d; -} - -QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const -{ - const QChar slash = QLatin1Char('/'); - QString url = urlIn.trimmed().replace(QLatin1Char('\\'), slash); - - // Remove postfixes - if (url.endsWith(d->mainLinePostfix)) - url.truncate(url.size() - d->mainLinePostfix.size()); - else if (url.endsWith(d->gitPostFix)) - url.truncate(url.size() - d->gitPostFix.size()); - - // extract repository name (last part of path) - int startOfRepoName = url.lastIndexOf(slash); - if (startOfRepoName == -1) - startOfRepoName = url.lastIndexOf(QLatin1Char(':')); - url.remove(0, startOfRepoName); - - // fix invalid characters - const QChar dash = QLatin1Char('-'); - url.replace(QRegExp(QLatin1String("[^0-9a-zA-Z_.-]")), dash); - // trim leading dashes (they are annoying and get created when using local pathes) - url.replace(QRegExp(QLatin1String("^-+")), QString()); - return url; -} - -QStringList CloneWizardPage::branches(const QString &repository, int *current) -{ - // Run git on remote repository if an URL was specified. - *current = -1; - - if (repository.isEmpty()) - return QStringList(); - const QStringList branches = Internal::GitPlugin::instance()->client()->synchronousRepositoryBranches(repository); - if (!branches.isEmpty()) - *current = 0; // default branch is always returned first! - return branches; -} - -bool CloneWizardPage::isRecursive() const -{ - return d->recursiveCheckBox->isChecked(); -} - -} // namespace Git - -#ifdef WITH_TESTS -#include <QTest> - -void Git::CloneWizardPage::testDirectoryFromRepository() -{ - QFETCH(QString, repository); - QFETCH(QString, localDirectory); - - QCOMPARE(directoryFromRepository(repository), localDirectory); -} -#endif diff --git a/src/plugins/git/clonewizardpage.h b/src/plugins/git/clonewizardpage.h deleted file mode 100644 index 4b14c6a3d36..00000000000 --- a/src/plugins/git/clonewizardpage.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARDPAGE_H -#define CLONEWIZARDPAGE_H - -#include <vcsbase/basecheckoutwizardpage.h> - -#include <utils/fileutils.h> - -namespace VcsBase { class VcsCommand; } - -namespace Git { - -struct CloneWizardPagePrivate; - -class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage -{ - Q_OBJECT -public: - explicit CloneWizardPage(QWidget *parent = 0); - ~CloneWizardPage(); - - QStringList branches(const QString &repository, int *current) override; - bool isRecursive() const; - -protected: - QString directoryFromRepository(const QString &r) const override; - -#ifdef WITH_TESTS -public: - void testDirectoryFromRepository(); -#endif - -private: - CloneWizardPagePrivate *d; -}; - -} // namespace Git -#endif // CLONEWIZARDPAGE_H diff --git a/src/plugins/git/git.pro b/src/plugins/git/git.pro index dba0e3733ca..9f8846e7b06 100644 --- a/src/plugins/git/git.pro +++ b/src/plugins/git/git.pro @@ -13,8 +13,6 @@ HEADERS += gitplugin.h \ gitsettings.h \ branchdialog.h \ branchmodel.h \ - clonewizard.h \ - clonewizardpage.h \ stashdialog.h \ gitutils.h \ remotemodel.h \ @@ -38,8 +36,6 @@ SOURCES += gitplugin.cpp \ gitsettings.cpp \ branchdialog.cpp \ branchmodel.cpp \ - clonewizard.cpp \ - clonewizardpage.cpp \ stashdialog.cpp \ gitutils.cpp \ remotemodel.cpp \ diff --git a/src/plugins/git/git.qbs b/src/plugins/git/git.qbs index 381168e73a1..5b1180033c2 100644 --- a/src/plugins/git/git.qbs +++ b/src/plugins/git/git.qbs @@ -28,10 +28,6 @@ QtcPlugin { "changeselectiondialog.cpp", "changeselectiondialog.h", "changeselectiondialog.ui", - "clonewizard.cpp", - "clonewizard.h", - "clonewizardpage.cpp", - "clonewizardpage.h", "commitdata.cpp", "commitdata.h", "git.qrc", diff --git a/src/plugins/git/git.qrc b/src/plugins/git/git.qrc index bab9c15f27a..f7c801436ad 100644 --- a/src/plugins/git/git.qrc +++ b/src/plugins/git/git.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/git"> - <file>images/git.png</file> <file>images/arrowup.png</file> <file>Git.mimetypes.xml</file> </qresource> diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 4d4fdb243d8..708ca4bd37e 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -39,7 +39,6 @@ #include "gitversioncontrol.h" #include "branchdialog.h" #include "remotedialog.h" -#include "clonewizard.h" #include "stashdialog.h" #include "settingspage.h" #include "logchangedialog.h" @@ -86,7 +85,6 @@ #include <QScopedPointer> #ifdef WITH_TESTS -#include "clonewizardpage.h" #include <QTest> #endif @@ -290,16 +288,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new GitSubmitEditor(&submitParameters); })); - auto cloneWizardFactory = new BaseCheckoutWizardFactory; - cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); - cloneWizardFactory->setIcon(QIcon(QLatin1String(":/git/images/git.png"))); - cloneWizardFactory->setDescription(tr("Clones a Git repository and tries to load the contained project.")); - cloneWizardFactory->setDisplayName(tr("Git Repository Clone")); - cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CloneWizard(path, parent); - }); - addAutoReleasedObject(cloneWizardFactory); - const QString prefix = QLatin1String("git"); m_commandLocator = new CommandLocator("Git", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -1540,27 +1528,6 @@ void GitPlugin::testLogResolving() "50a6b54c - Merge branch 'for-junio' of git://bogomips.org/git-svn", "3587b513 - Update draft release notes to 1.8.2"); } - -void GitPlugin::testCloneWizard_directoryFromRepository() -{ - CloneWizardPage page; - page.testDirectoryFromRepository(); -} - -void GitPlugin::testCloneWizard_directoryFromRepository_data() -{ - QTest::addColumn<QString>("repository"); - QTest::addColumn<QString>("localDirectory"); - - QTest::newRow("http") << "http://host/qt/qt.git" << "qt"; - QTest::newRow("without slash") << "user@host:qt.git" << "qt"; - QTest::newRow("mainline.git") << "git://gitorious.org/gitorious/mainline.git" << "gitorious"; - QTest::newRow("local repo (Unix)") << "/home/user/qt-creator.git" << "qt-creator"; - QTest::newRow("local repo (Windows)") << "c:\\repos\\qt-creator.git" << "qt-creator"; - QTest::newRow("ssh with port") << "ssh://host:29418/qt/qt.git" << "qt"; - QTest::newRow("invalid chars removed") << "ssh://host/in%va$lid.git" << "in-va-lid"; - QTest::newRow("leading dashs removed") << "https://gerrit.local/--leadingDash" << "leadingDash"; -} #endif } // namespace Internal diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 84d640b405f..d2219a535be 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -143,8 +143,6 @@ private slots: void testDiffFileResolving_data(); void testDiffFileResolving(); void testLogResolving(); - void testCloneWizard_directoryFromRepository(); - void testCloneWizard_directoryFromRepository_data(); #endif protected: void updateActions(VcsBase::VcsBasePlugin::ActionState) override; diff --git a/src/plugins/git/images/git.png b/src/plugins/git/images/git.png Binary files differdeleted file mode 100644 index 8895fe0165d..00000000000 --- a/src/plugins/git/images/git.png +++ /dev/null |