forked from qt-creator/qt-creator
VcsManager: Use more FilePath
Change-Id: I255372c47e6d3ea55e5f8060c3c2fdd9bd155c75 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user