diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-10-04 15:13:46 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-10-05 18:25:33 +0000 |
commit | 64db0009d551fa7147974c36502686605dacf3f7 (patch) | |
tree | 2afe658aaddf604011f4ad80e29134a20eee52e4 /src/plugins/git | |
parent | ab7a472b946cc84e6f4695dd6fb78b3b5a0377be (diff) |
VcsManager: Use more FilePath
Change-Id: I255372c47e6d3ea55e5f8060c3c2fdd9bd155c75
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/gerrit/gerritplugin.cpp | 25 | ||||
-rw-r--r-- | src/plugins/git/gerrit/gerritplugin.h | 2 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index e14a1da2c6..6d1431aac6 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -10,7 +10,6 @@ #include "../gitplugin.h" #include "../gitclient.h" -#include "../gitconstants.h" #include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseeditor.h> @@ -418,8 +417,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) // Ask the user for a repository to retrieve the change. const QString title = tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch); - const FilePath suggestedRespository = - FilePath::fromString(findLocalRepository(change->project, change->branch)); + const FilePath suggestedRespository = findLocalRepository(change->project, change->branch); repository = FileUtils::getExistingDirectory(m_dialog.data(), title, suggestedRespository); } @@ -433,35 +431,34 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) } // Try to find a matching repository for a project by asking the VcsManager. -QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const +FilePath GerritPlugin::findLocalRepository(const QString &project, const QString &branch) const { - const QStringList gitRepositories = VcsManager::repositories(GitPlugin::versionControl()); + const FilePaths gitRepositories = VcsManager::repositories(GitPlugin::versionControl()); // Determine key (file name) to look for (qt/qtbase->'qtbase'). const int slashPos = project.lastIndexOf('/'); - if (slashPos != -1) - project.remove(0, slashPos + 1); + const QString fixedProject = (slashPos < 0) ? project : project.mid(slashPos + 1); // When looking at branch 1.7, try to check folders // "qtbase_17", 'qtbase1.7' with a semi-smart regular expression. QScopedPointer<QRegularExpression> branchRegexp; if (!branch.isEmpty() && branch != "master") { QString branchPattern = branch; branchPattern.replace('.', "[\\.-_]?"); - const QString pattern = '^' + project + const QString pattern = '^' + fixedProject + "[-_]?" + branchPattern + '$'; branchRegexp.reset(new QRegularExpression(pattern)); if (!branchRegexp->isValid()) branchRegexp.reset(); // Oops. } - for (const QString &repository : gitRepositories) { - const QString fileName = Utils::FilePath::fromString(repository).fileName(); + for (const FilePath &repository : gitRepositories) { + const QString fileName = repository.fileName(); if ((!branchRegexp.isNull() && branchRegexp->match(fileName).hasMatch()) - || fileName == project) { + || fileName == fixedProject) { // Perform a check on the branch. if (branch.isEmpty()) { return repository; } else { - const QString repositoryBranch = GerritPlugin::branch(FilePath::fromString(repository)); + const QString repositoryBranch = GerritPlugin::branch(repository); if (repositoryBranch.isEmpty() || repositoryBranch == branch) return repository; } // !branch.isEmpty() @@ -469,9 +466,9 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch } // for repositories // No match, do we have a projects folder? if (DocumentManager::useProjectsDirectory()) - return DocumentManager::projectsDirectory().toString(); + return DocumentManager::projectsDirectory(); - return QDir::currentPath(); + return FilePath::currentWorkingPath(); } } // namespace Internal diff --git a/src/plugins/git/gerrit/gerritplugin.h b/src/plugins/git/gerrit/gerritplugin.h index 4d39b139f7..46431b2761 100644 --- a/src/plugins/git/gerrit/gerritplugin.h +++ b/src/plugins/git/gerrit/gerritplugin.h @@ -50,7 +50,7 @@ private: void openView(); void push(); - QString findLocalRepository(QString project, const QString &branch) const; + Utils::FilePath findLocalRepository(const QString &project, const QString &branch) const; void fetch(const QSharedPointer<GerritChange> &change, int mode); QSharedPointer<GerritParameters> m_parameters; |