-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add issue link support and templates for plain links (#109)
* feat: add issue link support and templates for plain links * fix by Codacy Static Code Analysis * fix at CreateFor
- Loading branch information
Showing
20 changed files
with
340 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using LibGit2Sharp; | ||
using NuGet.Versioning; | ||
using Shouldly; | ||
using Versionize.Changelog; | ||
using Versionize.Tests.TestSupport; | ||
using Xunit; | ||
|
||
namespace Versionize.Tests.Changelog; | ||
|
||
public class PlainLinkBuilderTest | ||
{ | ||
[Fact] | ||
public void ShouldCreatePlainLinkBuilder() | ||
{ | ||
var repo = SetupRepositoryWithRemote("origin", "https://hostmeister.com/versionize/versionize.git"); | ||
var linkBuilder = LinkBuilderFactory.CreateFor(repo); | ||
|
||
linkBuilder.ShouldBeAssignableTo<PlainLinkBuilder>(); | ||
|
||
linkBuilder.BuildIssueLink("123") | ||
.ShouldBeEmpty(); | ||
linkBuilder.BuildCommitLink( | ||
new ConventionalCommit | ||
{ | ||
Sha = "734713bc047d87bf7eac9674765ae793478c50d3" | ||
}) | ||
.ShouldBeEmpty(); | ||
linkBuilder.BuildVersionTagLink( | ||
new SemanticVersion(1, 2, 3)) | ||
.ShouldBeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildCustomLinks() | ||
{ | ||
var repo = SetupRepositoryWithRemote("origin", "https://hostmeister.com/versionize/versionize.git"); | ||
var linkBuilder = LinkBuilderFactory.CreateFor( | ||
repo, | ||
new PlainLinkTemplates | ||
{ | ||
IssueLink = "https://my-repo/issues/{issue}", | ||
CommitLink = "https://my-repo/commits/{commitSha}", | ||
VersionTagLink = "https://my-repo/tags/v{version}", | ||
}); | ||
|
||
linkBuilder.ShouldBeAssignableTo<PlainLinkBuilder>(); | ||
|
||
linkBuilder.BuildIssueLink("123") | ||
.ShouldBe("https://my-repo/issues/123"); | ||
linkBuilder.BuildCommitLink( | ||
new ConventionalCommit | ||
{ | ||
Sha = "734713bc047d87bf7eac9674765ae793478c50d3" | ||
}) | ||
.ShouldBe("https://my-repo/commits/734713bc047d87bf7eac9674765ae793478c50d3"); | ||
linkBuilder.BuildVersionTagLink( | ||
new SemanticVersion(1, 2, 3)) | ||
.ShouldBe("https://my-repo/tags/v1.2.3"); | ||
} | ||
|
||
private static Repository SetupRepositoryWithRemote(string remoteName, string pushUrl) | ||
{ | ||
var workingDirectory = TempDir.Create(); | ||
var repo = TempRepository.Create(workingDirectory); | ||
|
||
foreach (var existingRemoteName in repo.Network.Remotes.Select(remote => remote.Name)) | ||
{ | ||
repo.Network.Remotes.Remove(existingRemoteName); | ||
} | ||
|
||
repo.Network.Remotes.Add(remoteName, pushUrl); | ||
|
||
return repo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.