summaryrefslogtreecommitdiff
path: root/src/plugins/git/gerrit/gerritdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/git/gerrit/gerritdialog.cpp')
-rw-r--r--src/plugins/git/gerrit/gerritdialog.cpp40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp
index 78b8bbd36d..43f71b50c4 100644
--- a/src/plugins/git/gerrit/gerritdialog.cpp
+++ b/src/plugins/git/gerrit/gerritdialog.cpp
@@ -230,8 +230,6 @@ void GerritDialog::updateRemotes()
if (m_repository.isEmpty() || !QFileInfo(m_repository).isDir())
return;
m_updatingRemotes = true;
- static const QRegularExpression sshPattern(
- "^(?:(?<protocol>[^:]+)://)?(?:(?<user>[^@]+)@)?(?<host>[^:/]+)(?::(?<port>\\d+))?");
*m_server = m_parameters->server;
QString errorMessage; // Mute errors. We'll just fallback to the defaults
QMap<QString, QString> remotesList =
@@ -239,35 +237,14 @@ void GerritDialog::updateRemotes()
QMapIterator<QString, QString> mapIt(remotesList);
while (mapIt.hasNext()) {
mapIt.next();
- const QString r = mapIt.value();
- // Skip local remotes (refer to the root or relative path)
- if (r.isEmpty() || r.startsWith('/') || r.startsWith('.'))
- continue;
- // On Windows, local paths typically starts with <drive>:
- if (Utils::HostOsInfo::isWindowsHost() && r[1] == ':')
- continue;
GerritServer server;
- QRegularExpressionMatch match = sshPattern.match(r);
- if (match.hasMatch()) {
- const QString protocol = match.captured("protocol");
- if (protocol == "https")
- server.type = GerritServer::Https;
- else if (protocol == "http")
- server.type = GerritServer::Http;
- else if (protocol.isEmpty() || protocol == "ssh")
- server.type = GerritServer::Ssh;
- else
- continue;
- const QString user = match.captured("user");
- server.user = user.isEmpty() ? m_parameters->server.user : user;
- server.host = match.captured("host");
- server.port = match.captured("port").toUShort();
- // Only Ssh is currently supported. In order to extend support for http[s],
- // we need to move this logic to the model, and attempt connection to each
- // remote (do it only on refresh, not on each path change)
- if (server.type == GerritServer::Ssh)
- addRemote(server, mapIt.key());
- }
+ if (!server.fillFromRemote(mapIt.value(), m_parameters->server.user))
+ continue;
+ // Only Ssh is currently supported. In order to extend support for http[s],
+ // we need to move this logic to the model, and attempt connection to each
+ // remote (do it only on refresh, not on each path change)
+ if (server.type == GerritServer::Ssh)
+ addRemote(server, mapIt.key());
}
addRemote(m_parameters->server, tr("Fallback"));
m_updatingRemotes = false;
@@ -276,9 +253,6 @@ void GerritDialog::updateRemotes()
void GerritDialog::addRemote(const GerritServer &server, const QString &name)
{
- // Clearly not gerrit
- if (server.host.contains("github.com"))
- return;
for (int i = 0, total = m_ui->remoteComboBox->count(); i < total; ++i) {
const GerritServer s = m_ui->remoteComboBox->itemData(i).value<GerritServer>();
if (s.host == server.host)