Skip to content
This repository was archived by the owner on May 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/Server.Tests/Server.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.15" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Octopus.Server.Extensibility" Version="10.0.4" />
<PackageReference Include="Octopus.Server.Extensibility" Version="13.0.0" />
<ProjectReference Include="..\Server\Server.csproj" />
</ItemGroup>

Expand Down
12 changes: 6 additions & 6 deletions source/Server.Tests/WorkItemLinkMapperScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ILog>()).GetReleaseNote(vcsRoot, issueNumber, linkData, releaseNotePrefix);
return new WorkItemLinkMapper(Substitute.For<ISystemLog>(), 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")]
Expand All @@ -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<Octokit.Label>(), null, new List<Octokit.User>(), null, 0, null, null, DateTimeOffset.Now, null, workItemNumber, "node", false, null, null));

var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, Substitute.For<ILog>());
var mapper = new WorkItemLinkMapper(Substitute.For<ISystemLog>(), store, new CommentParser(), githubClientLazy);

var workItems = mapper.Map(new OctopusBuildInformation
{
Expand Down Expand Up @@ -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<Octokit.Label>(), null, new List<Octokit.User>(), null, 0, null, null, DateTimeOffset.Now, null, workItemNumber, "node", false, null, null));

var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, Substitute.For<ILog>());
var mapper = new WorkItemLinkMapper(Substitute.For<ISystemLog>(), store, new CommentParser(), githubClientLazy);

var workItems = mapper.Map(new OctopusBuildInformation
{
Expand All @@ -132,9 +132,9 @@ public void AzureDevOpsGitCommentsGetIgnored()
store.GetBaseUrl().Returns("https://github.com");
store.GetIsEnabled().Returns(true);

var log = Substitute.For<ILog>();
var log = Substitute.For<ISystemLog>();

var mapper = new WorkItemLinkMapper(store, new CommentParser(), githubClientLazy, log);
var mapper = new WorkItemLinkMapper(log, store, new CommentParser(), githubClientLazy);

var workItems = mapper.Map(new OctopusBuildInformation
{
Expand All @@ -147,7 +147,7 @@ public void AzureDevOpsGitCommentsGetIgnored()
});
var success = workItems as ISuccessResult<WorkItemLink[]>;
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");
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/Server/Configuration/DatabaseInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions source/Server/Configuration/GitHubConfigureCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ namespace Octopus.Server.Extensibility.IssueTracker.GitHub.Configuration
{
class GitHubConfigureCommands : IContributeToConfigureCommand
{
readonly ILog log;
readonly Lazy<IGitHubConfigurationStore> GitHubConfiguration;
readonly ISystemLog systemLog;
readonly Lazy<IGitHubConfigurationStore> gitHubConfiguration;

public GitHubConfigureCommands(
ILog log,
ISystemLog systemLog,
Lazy<IGitHubConfigurationStore> gitHubConfiguration)
{
this.log = log;
this.GitHubConfiguration = gitHubConfiguration;
this.systemLog = systemLog;
this.gitHubConfiguration = gitHubConfiguration;
}

public IEnumerable<ConfigureCommandOption> 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}");
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions source/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Octokit" Version="0.32.0" />
<PackageReference Include="Octopus.Data" Version="5.1.3" />
<PackageReference Include="Octopus.Diagnostics" Version="1.3.5" />
<PackageReference Include="Octopus.Server.Extensibility" Version="10.0.4" />
<PackageReference Include="Octopus.Data" Version="5.3.0" />
<PackageReference Include="Octopus.Diagnostics" Version="2.1.0" />
<PackageReference Include="Octopus.Server.Extensibility" Version="13.0.0" />
</ItemGroup>
</Project>
13 changes: 6 additions & 7 deletions source/Server/WorkItems/WorkItemLinkMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IGitHubClient> 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<IGitHubClient> githubClient,
ILog log)
Lazy<IGitHubClient> githubClient)
{
this.systemLog = systemLog;
this.store = store;
this.commentParser = commentParser;
this.githubClient = githubClient;
this.log = log;
}

public string CommentParser => GitHubConfigurationStore.CommentParser;
Expand All @@ -49,7 +48,7 @@ public IResultFromExtension<WorkItemLink[]> 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<WorkItemLink[]>.Success(new WorkItemLink[0]);
}

Expand Down