Skip to content

Commit bb3c3ac

Browse files
committed
Merge branch 'hotfix/0.10.4'
2 parents f2b740d + e3380f1 commit bb3c3ac

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [vNext]
88

9+
## [0.10.4] / 2018-10-10
10+
- Fixed `GitRepository` when origin url is a ssh url without username.
11+
912
## [0.10.3] / 2018-10-05
1013
- Fixed `WinRelativePath` and `UnixRelativePath` to use correct separator
1114

@@ -167,7 +170,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
167170
- Added CLT tasks for Git
168171
- Fixed background color in console output
169172

170-
[vNext]: https://github.com/nuke-build/nuke/compare/0.10.3...HEAD
173+
[vNext]: https://github.com/nuke-build/nuke/compare/0.10.4...HEAD
174+
[0.10.4]: https://github.com/nuke-build/nuke/compare/0.10.3...0.10.4
171175
[0.10.3]: https://github.com/nuke-build/nuke/compare/0.10.2...0.10.3
172176
[0.10.2]: https://github.com/nuke-build/nuke/compare/0.10.1...0.10.2
173177
[0.10.1]: https://github.com/nuke-build/nuke/compare/0.10.0...0.10.1

source/Nuke.Common.Tests/GitRepositoryTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ public class GitRepositoryTest
2626
[InlineData("[email protected]/test/", "git.test.org", "test")]
2727
[InlineData("[email protected]/test.git", "git.test.org", "test")]
2828
[InlineData("ssh://[email protected]/test.git", "git.test.org", "test")]
29+
[InlineData("ssh://[email protected]:1234/test.git", "git.test.org", "test")]
30+
[InlineData("ssh://git.test.org/test/test", "git.test.org", "test/test")]
31+
[InlineData("ssh://git.test.org:1234/test/test", "git.test.org", "test/test")]
32+
[InlineData("https://git.test.org:1234/test/test", "git.test.org", "test/test")]
33+
[InlineData("git://git.test.org:1234/test/test", "git.test.org", "test/test")]
34+
[InlineData("git://git.test.org/test/test", "git.test.org", "test/test")]
2935
public void FromUrlTest(string url, string endpoint, string identifier)
3036
{
3137
var repository = GitRepository.FromUrl(url);

source/Nuke.Common/Git/GitRepository.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,10 @@ public static GitRepository FromLocalDirectory(string directory, string branch =
6161

6262
private static (string endpoint, string identifier) ParseUrl(string url)
6363
{
64-
var match = new[]
65-
{
66-
@"git@(?<endpoint>[^:/]+?)(:|/)(?<identifier>.+?)/?(\.git)?$",
67-
@"^https?://([^:]+:[^:@]+@)?(?<endpoint>[^/]+?)/(?<identifier>.+?)/?(\.git)?$"
68-
}
69-
.Select(x => Regex.Match(url.Trim(), x))
70-
.FirstOrDefault(x => x.Success);
71-
ControlFlow.Assert(match != null, $"Url '{url}' could not be parsed.");
72-
64+
var regex = new Regex(@"^(?'protocol'\w+\:\/\/)?(?>(?'user'.*)@)?(?'endpoint'[^\/:]+)(?>\:(?'port'\d+))?[\/:](?'identifier'.*?)\/?(?>\.git)?$");
65+
var match = regex.Match(url.Trim());
66+
67+
ControlFlow.Assert(match.Success, $"Url '{url}' could not be parsed.");
7368
return (match.Groups["endpoint"].Value, match.Groups["identifier"].Value);
7469
}
7570

0 commit comments

Comments
 (0)