diff --git a/source/Server.Tests/Server.Tests.csproj b/source/Server.Tests/Server.Tests.csproj index 8c8bcf5..21f9227 100644 --- a/source/Server.Tests/Server.Tests.csproj +++ b/source/Server.Tests/Server.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/source/Server.Tests/WorkItemLinkMapperScenarios.cs b/source/Server.Tests/WorkItemLinkMapperScenarios.cs index e34ef48..1ff0670 100644 --- a/source/Server.Tests/WorkItemLinkMapperScenarios.cs +++ b/source/Server.Tests/WorkItemLinkMapperScenarios.cs @@ -51,7 +51,7 @@ public string GetWorkItemDescription(string vcsRoot, string issueNumber, string new IssueComment(0, null, null, null, releaseNoteComment, DateTimeOffset.Now, null, null, null) }); - return new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, Substitute.For()).GetReleaseNote(vcsRoot, issueNumber, linkData, releaseNotePrefix); + return new WorkItemLinkMapper(Substitute.For(), store, new CommentParser(), githubClientLazy).GetReleaseNote(vcsRoot, issueNumber, linkData, releaseNotePrefix); } [TestCase("https://github.com", "https://github.com/UserX/RepoY", "#1234", ExpectedResult = "https://github.com/UserX/RepoY/issues/1234")] @@ -78,7 +78,7 @@ public void DuplicatesGetIgnored() githubClient.Issue.Get(Arg.Is("UserX"), Arg.Is("RepoY"), Arg.Is(workItemNumber)) .Returns(new Issue("url", "htmlUrl", "commentUrl", "eventsUrl", workItemNumber, ItemState.Open, "Test title", "test body", null, null, new List(), null, new List(), null, 0, null, null, DateTimeOffset.Now, null, workItemNumber, "node", false, null, null)); - var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, Substitute.For()); + var mapper = new WorkItemLinkMapper(Substitute.For(), store, new CommentParser(), githubClientLazy); var workItems = mapper.Map(new OctopusBuildInformation { @@ -108,7 +108,7 @@ public void SourceGetsSet() githubClient.Issue.Get(Arg.Is("UserX"), Arg.Is("RepoY"), Arg.Is(workItemNumber)) .Returns(new Issue("url", "htmlUrl", "commentUrl", "eventsUrl", workItemNumber, ItemState.Open, "Test title", "test body", null, null, new List(), null, new List(), null, 0, null, null, DateTimeOffset.Now, null, workItemNumber, "node", false, null, null)); - var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, Substitute.For()); + var mapper = new WorkItemLinkMapper(Substitute.For(), store, new CommentParser(), githubClientLazy); var workItems = mapper.Map(new OctopusBuildInformation { @@ -132,9 +132,9 @@ public void AzureDevOpsGitCommentsGetIgnored() store.GetBaseUrl().Returns("https://github.com"); store.GetIsEnabled().Returns(true); - var log = Substitute.For(); + var log = Substitute.For(); - var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, log); + var mapper = new WorkItemLinkMapper(log, store, new CommentParser(), githubClientLazy); var workItems = mapper.Map(new OctopusBuildInformation { @@ -147,7 +147,7 @@ public void AzureDevOpsGitCommentsGetIgnored() }); var success = workItems as ISuccessResult; Assert.IsNotNull(success, "AzureDevOps VCS root should not be a failure"); - Assert.IsEmpty(success.Value, "AzureDevOps VCS root should return an empty list of links"); + Assert.IsEmpty(success!.Value, "AzureDevOps VCS root should return an empty list of links"); log.Received(1).WarnFormat("The VCS Root '{0}' indicates this build information is Azure DevOps related so GitHub comment references will be ignored", "https://something.com/_git/ProjectX"); } } diff --git a/source/Server/Configuration/DatabaseInitializer.cs b/source/Server/Configuration/DatabaseInitializer.cs index 7e1464c..e02284b 100644 --- a/source/Server/Configuration/DatabaseInitializer.cs +++ b/source/Server/Configuration/DatabaseInitializer.cs @@ -6,12 +6,12 @@ namespace Octopus.Server.Extensibility.IssueTracker.GitHub.Configuration { class DatabaseInitializer : ExecuteWhenDatabaseInitializes { - readonly ILog log; + readonly ISystemLog systemLog; readonly IConfigurationStore configurationStore; - public DatabaseInitializer(ILog log, IConfigurationStore configurationStore) + public DatabaseInitializer(ISystemLog systemLog, IConfigurationStore configurationStore) { - this.log = log; + this.systemLog = systemLog; this.configurationStore = configurationStore; } @@ -21,7 +21,7 @@ public override void Execute() if (doc != null) return; - log.Info("Initializing GitHub integration settings"); + systemLog.Info("Initializing GitHub integration settings"); doc = new GitHubConfiguration(); configurationStore.Create(doc); } diff --git a/source/Server/Configuration/GitHubConfigureCommands.cs b/source/Server/Configuration/GitHubConfigureCommands.cs index 3ed109b..8e8f2be 100644 --- a/source/Server/Configuration/GitHubConfigureCommands.cs +++ b/source/Server/Configuration/GitHubConfigureCommands.cs @@ -7,15 +7,15 @@ namespace Octopus.Server.Extensibility.IssueTracker.GitHub.Configuration { class GitHubConfigureCommands : IContributeToConfigureCommand { - readonly ILog log; - readonly Lazy GitHubConfiguration; + readonly ISystemLog systemLog; + readonly Lazy gitHubConfiguration; public GitHubConfigureCommands( - ILog log, + ISystemLog systemLog, Lazy gitHubConfiguration) { - this.log = log; - this.GitHubConfiguration = gitHubConfiguration; + this.systemLog = systemLog; + this.gitHubConfiguration = gitHubConfiguration; } public IEnumerable GetOptions() @@ -23,13 +23,13 @@ public IEnumerable GetOptions() yield return new ConfigureCommandOption("GitHubIsEnabled=", "Set whether GitHub issue tracker integration is enabled.", v => { var isEnabled = bool.Parse(v); - GitHubConfiguration.Value.SetIsEnabled(isEnabled); - log.Info($"GitHub Issue Tracker integration IsEnabled set to: {isEnabled}"); + gitHubConfiguration.Value.SetIsEnabled(isEnabled); + systemLog.Info($"GitHub Issue Tracker integration IsEnabled set to: {isEnabled}"); }); yield return new ConfigureCommandOption("GitHubBaseUrl=", GitHubConfigurationResource.GitHubBaseUrlDescription, v => { - GitHubConfiguration.Value.SetBaseUrl(v); - log.Info($"GitHub Issue Tracker integration base Url set to: {v}"); + gitHubConfiguration.Value.SetBaseUrl(v); + systemLog.Info($"GitHub Issue Tracker integration base Url set to: {v}"); }); } } diff --git a/source/Server/Server.csproj b/source/Server/Server.csproj index 36b2817..856b401 100644 --- a/source/Server/Server.csproj +++ b/source/Server/Server.csproj @@ -14,8 +14,8 @@ - - - + + + \ No newline at end of file diff --git a/source/Server/WorkItems/WorkItemLinkMapper.cs b/source/Server/WorkItems/WorkItemLinkMapper.cs index a80ba24..9af9e0f 100644 --- a/source/Server/WorkItems/WorkItemLinkMapper.cs +++ b/source/Server/WorkItems/WorkItemLinkMapper.cs @@ -14,22 +14,21 @@ namespace Octopus.Server.Extensibility.IssueTracker.GitHub.WorkItems { class WorkItemLinkMapper : IWorkItemLinkMapper { + private readonly ISystemLog systemLog; private readonly IGitHubConfigurationStore store; private readonly CommentParser commentParser; private readonly Lazy githubClient; - private readonly ILog log; private readonly Regex ownerRepoRegex = new Regex("(?:https?://)?(?:[^?/\\s]+[?/])(.*)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public WorkItemLinkMapper(IGitHubConfigurationStore store, + public WorkItemLinkMapper(ISystemLog systemLog, + IGitHubConfigurationStore store, CommentParser commentParser, - Lazy githubClient, - ILog log) + Lazy githubClient) { + this.systemLog = systemLog; this.store = store; this.commentParser = commentParser; this.githubClient = githubClient; - this.log = log; } public string CommentParser => GitHubConfigurationStore.CommentParser; @@ -49,7 +48,7 @@ public IResultFromExtension Map(OctopusBuildInformation buildInf const string pathComponentIndicatingAzureDevOpsVcs = @"/_git/"; if (buildInformation.VcsRoot.Contains(pathComponentIndicatingAzureDevOpsVcs)) { - log.WarnFormat("The VCS Root '{0}' indicates this build information is Azure DevOps related so GitHub comment references will be ignored", buildInformation.VcsRoot); + systemLog.WarnFormat("The VCS Root '{0}' indicates this build information is Azure DevOps related so GitHub comment references will be ignored", buildInformation.VcsRoot); return ResultFromExtension.Success(new WorkItemLink[0]); }