Skip to content

Commit

Permalink
Corrected registration
Browse files Browse the repository at this point in the history
  • Loading branch information
credfeto committed Dec 21, 2023
1 parent eb16a1d commit eb0039a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/FunFair.BuildVersion.Detection/VersionDetectionSetup.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using FunFair.BuildVersion.Detection.ExternalBranchLocators;
using FunFair.BuildVersion.Interfaces;
using LibGit2Sharp;
using Microsoft.Extensions.DependencyInjection;

namespace FunFair.BuildVersion.Detection;

public static class VersionDetectionSetup
{
public static IServiceCollection AddBuildVersionDetection(this IServiceCollection services, Repository repo, IBranchSettings branchSettings)
public static IServiceCollection AddBuildVersionDetection(this IServiceCollection services, IBranchSettings branchSettings)
{
return services.AddSingleton(branchSettings)
.AddSingleton(repo)
.AddSingleton<IBranchDiscovery, GitBranchDiscovery>()
.AddSingleton<IBranchClassification, BranchClassification>()
.AddSingleton<IVersionDetector, VersionDetector>()
Expand Down
6 changes: 3 additions & 3 deletions src/FunFair.BuildVersion/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static int ParsedOk(Options options)

using (Repository repository = OpenRepository(workDir))
{
IServiceProvider serviceProvider = Setup(options: options, repo: repository);
IServiceProvider serviceProvider = Setup(options: options);

IDiagnosticLogger logging = serviceProvider.GetRequiredService<IDiagnosticLogger>();
IVersionDetector versionDetector = serviceProvider.GetRequiredService<IVersionDetector>();
Expand Down Expand Up @@ -89,7 +89,7 @@ public static int Main(params string[] args)
}
}

private static IServiceProvider Setup(Options options, Repository repo)
private static IServiceProvider Setup(Options options)
{
IServiceCollection services = new ServiceCollection();
DiagnosticLogger logger = new(options.WarningsAsErrors);
Expand All @@ -99,7 +99,7 @@ private static IServiceProvider Setup(Options options, Repository repo)
services.AddSingleton<ILogger>(logger)
.AddSingleton<IDiagnosticLogger>(logger)
.AddSingleton(typeof(ILogger<>), typeof(LoggerProxy<>))
.AddBuildVersionDetection(repo: repo, branchSettings: branchSettings)
.AddBuildVersionDetection(branchSettings: branchSettings)
.AddSingleton<IVersionPublisher, GitHubActionsVersionPublisher>()
.AddSingleton<IVersionPublisher, TeamCityVersionPublisher>();

Expand Down

0 comments on commit eb0039a

Please sign in to comment.