Skip to content

Commit

Permalink
Merge branch 'hotfix/0.10.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Oct 10, 2018
2 parents f2b740d + e3380f1 commit bb3c3ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [vNext]

## [0.10.4] / 2018-10-10
- Fixed `GitRepository` when origin url is a ssh url without username.

## [0.10.3] / 2018-10-05
- Fixed `WinRelativePath` and `UnixRelativePath` to use correct separator

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

[vNext]: https://github.com/nuke-build/nuke/compare/0.10.3...HEAD
[vNext]: https://github.com/nuke-build/nuke/compare/0.10.4...HEAD
[0.10.4]: https://github.com/nuke-build/nuke/compare/0.10.3...0.10.4
[0.10.3]: https://github.com/nuke-build/nuke/compare/0.10.2...0.10.3
[0.10.2]: https://github.com/nuke-build/nuke/compare/0.10.1...0.10.2
[0.10.1]: https://github.com/nuke-build/nuke/compare/0.10.0...0.10.1
Expand Down
6 changes: 6 additions & 0 deletions source/Nuke.Common.Tests/GitRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class GitRepositoryTest
[InlineData("[email protected]/test/", "git.test.org", "test")]
[InlineData("[email protected]/test.git", "git.test.org", "test")]
[InlineData("ssh://[email protected]/test.git", "git.test.org", "test")]
[InlineData("ssh://[email protected]:1234/test.git", "git.test.org", "test")]
[InlineData("ssh://git.test.org/test/test", "git.test.org", "test/test")]
[InlineData("ssh://git.test.org:1234/test/test", "git.test.org", "test/test")]
[InlineData("https://git.test.org:1234/test/test", "git.test.org", "test/test")]
[InlineData("git://git.test.org:1234/test/test", "git.test.org", "test/test")]
[InlineData("git://git.test.org/test/test", "git.test.org", "test/test")]
public void FromUrlTest(string url, string endpoint, string identifier)
{
var repository = GitRepository.FromUrl(url);
Expand Down
13 changes: 4 additions & 9 deletions source/Nuke.Common/Git/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,10 @@ public static GitRepository FromLocalDirectory(string directory, string branch =

private static (string endpoint, string identifier) ParseUrl(string url)
{
var match = new[]
{
@"git@(?<endpoint>[^:/]+?)(:|/)(?<identifier>.+?)/?(\.git)?$",
@"^https?://([^:]+:[^:@]+@)?(?<endpoint>[^/]+?)/(?<identifier>.+?)/?(\.git)?$"
}
.Select(x => Regex.Match(url.Trim(), x))
.FirstOrDefault(x => x.Success);
ControlFlow.Assert(match != null, $"Url '{url}' could not be parsed.");

var regex = new Regex(@"^(?'protocol'\w+\:\/\/)?(?>(?'user'.*)@)?(?'endpoint'[^\/:]+)(?>\:(?'port'\d+))?[\/:](?'identifier'.*?)\/?(?>\.git)?$");
var match = regex.Match(url.Trim());

ControlFlow.Assert(match.Success, $"Url '{url}' could not be parsed.");
return (match.Groups["endpoint"].Value, match.Groups["identifier"].Value);
}

Expand Down

0 comments on commit bb3c3ac

Please sign in to comment.