Git: Add support for github remotes

Github and gitlab uses a different syntax when cloning with ssh:

 git@github.com:qt-creator/qt-creator.git

Support this pattern for remote validatation also.

Change-Id: Ic67f2238b9cdd526e76715c86846542cdb73f503
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Andre Hartmann
2018-10-07 15:29:28 +02:00
committed by André Hartmann
parent 96f982a016
commit 3177e53804
2 changed files with 6 additions and 1 deletions

View File

@@ -3378,7 +3378,7 @@ GitRemote::GitRemote(const QString &url)
{ {
static const QRegularExpression remotePattern( static const QRegularExpression remotePattern(
"^(?:(?<protocol>[^:]+)://)?(?:(?<user>[^@]+)@)?(?<host>[^:/]+)" "^(?:(?<protocol>[^:]+)://)?(?:(?<user>[^@]+)@)?(?<host>[^:/]+)"
"(?::(?<port>\\d+))?:?(?<path>/.*)$"); "(?::(?<port>\\d+))?:?(?<path>.*)$");
if (url.isEmpty()) if (url.isEmpty())
return; return;

View File

@@ -1612,6 +1612,11 @@ void GitPlugin::testGitRemote_data()
.host("codereview.qt-project.org") .host("codereview.qt-project.org")
.port(29418) .port(29418)
.path("/qt-creator/qt-creator.git"); .path("/qt-creator/qt-creator.git");
QTest::newRow("ssh-github")
<< RemoteTest("git@github.com:qt-creator/qt-creator.git")
.userName("git")
.host("github.com")
.path("qt-creator/qt-creator.git");
QTest::newRow("local-file-protocol") QTest::newRow("local-file-protocol")
<< RemoteTest("file:///tmp/myrepo.git") << RemoteTest("file:///tmp/myrepo.git")
.protocol("file") .protocol("file")