public static IChangelogLinkBuilder CreateFor(Repository repository) { var origin = repository.Network.Remotes.FirstOrDefault(remote => remote.Name == "origin") ?? repository.Network.Remotes.FirstOrDefault(); if (origin == null) { return(new PlainLinkBuilder()); } if (GithubLinkBuilder.IsPushUrl(origin.PushUrl)) { return(new GithubLinkBuilder(origin.PushUrl)); } else if (AzureLinkBuilder.IsPushUrl(origin.PushUrl)) { return(new AzureLinkBuilder(origin.PushUrl)); } else if (GitlabLinkBuilder.IsPushUrl(origin.PushUrl)) { return(new GitlabLinkBuilder(origin.PushUrl)); } else if (BitbucketLinkBuilder.IsPushUrl(origin.PushUrl)) { return(new BitbucketLinkBuilder(origin.PushUrl)); } return(new PlainLinkBuilder()); }
public void ShouldBuildGithubSSHCommitLinks() { var linkBuilder = new GithubLinkBuilder("[email protected]:organization/repository.git"); var changelog = Changelog.Discover(_testDirectory); changelog.Write(new Version(1, 0, 0), new DateTimeOffset(), linkBuilder, new List <ConventionalCommit> { ConventionalCommitParser.Parse(new TestCommit("a360d6a307909c6e571b29d4a329fd786c5d4543", "fix: a fix in version 1.0.0")), }); var changelogContents = File.ReadAllText(changelog.FilePath); changelogContents.ShouldContain("* a fix in version 1.0.0 ([a360d6a](https://www.github.com/organization/repository/commit/a360d6a307909c6e571b29d4a329fd786c5d4543))"); }