// Try to find a matching repository for a project by asking the VcsManager. QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const { const QStringList gitRepositories = VcsManager::repositories(GitPlugin::instance()->gitVersionControl()); // Determine key (file name) to look for (qt/qtbase->'qtbase'). const int slashPos = project.lastIndexOf('/'); if (slashPos != -1) project.remove(0, slashPos + 1); // When looking at branch 1.7, try to check folders // "qtbase_17", 'qtbase1.7' with a semi-smart regular expression. QScopedPointer<QRegExp> branchRegexp; if (!branch.isEmpty() && branch != "master") { QString branchPattern = branch; branchPattern.replace('.', "[\\.-_]?"); const QString pattern = '^' + project + "[-_]?" + branchPattern + '$'; branchRegexp.reset(new QRegExp(pattern)); if (!branchRegexp->isValid()) branchRegexp.reset(); // Oops. } for (const QString &repository : gitRepositories) { const QString fileName = Utils::FileName::fromString(repository).fileName(); if ((!branchRegexp.isNull() && branchRegexp->exactMatch(fileName)) || fileName == project) { // Perform a check on the branch. if (branch.isEmpty()) { return repository; } else { const QString repositoryBranch = GerritPlugin::branch(repository); if (repositoryBranch.isEmpty() || repositoryBranch == branch) return repository; } // !branch.isEmpty() } // branchRegexp or file name match } // for repositories // No match, do we have a projects folder? if (DocumentManager::useProjectsDirectory()) return DocumentManager::projectsDirectory().toString(); return QDir::currentPath(); }