Skip to content

Commit 6885300

Browse files
committed
cleanup
1 parent be1656f commit 6885300

29 files changed

+74
-70
lines changed

src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using GitVersion;
55
using GitVersion.Configuration;
66
using GitVersion.VersionCalculation;
7-
using GitVersion.VersionCalculation.BaseVersionCalculators;
87
using GitVersion.VersionFilters;
98
using GitVersionCore.Tests.Mocks;
109
using LibGit2Sharp;

src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Linq;
22
using GitVersion.Configuration;
33
using GitVersion.VersionCalculation;
4-
using GitVersion.VersionCalculation.BaseVersionCalculators;
54
using GitVersionCore.Tests.Helpers;
65
using NUnit.Framework;
76
using Shouldly;

src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Linq;
33
using GitVersion.Configuration;
44
using GitVersion.Logging;
5-
using GitVersion.VersionCalculation.BaseVersionCalculators;
5+
using GitVersion.VersionCalculation;
66
using GitVersionCore.Tests.Helpers;
77
using GitVersionCore.Tests.Mocks;
88
using LibGit2Sharp;

src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using GitVersion.Configuration;
66
using GitVersion.Logging;
77
using GitVersion.VersionCalculation;
8-
using GitVersion.VersionCalculation.BaseVersionCalculators;
98
using GitVersionCore.Tests.Helpers;
109
using LibGit2Sharp;
1110
using NUnit.Framework;

src/GitVersionCore.Tests/VersionCalculation/TestBaseVersionCalculator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GitVersion;
22
using GitVersion.VersionCalculation;
3-
using GitVersion.VersionCalculation.BaseVersionCalculators;
43
using LibGit2Sharp;
54

65
namespace GitVersionCore.Tests.VersionCalculation

src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GitVersion.VersionCalculation.BaseVersionCalculators;
1+
using GitVersion.VersionCalculation;
22
using GitVersion.VersionFilters;
33
using NUnit.Framework;
44
using Shouldly;

src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using GitVersion;
3-
using GitVersion.VersionCalculation.BaseVersionCalculators;
3+
using GitVersion.VersionCalculation;
44
using GitVersion.VersionFilters;
55
using GitVersionCore.Tests.Helpers;
66
using NUnit.Framework;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Reflection;
2+
using Microsoft.Extensions.DependencyInjection;
3+
4+
namespace GitVersion.BuildServers
5+
{
6+
public class BuildServerModule : GitVersionModule
7+
{
8+
public override void RegisterTypes(IServiceCollection services)
9+
{
10+
var buildServers = FindAllDerivedTypes<BuildServerBase>(Assembly.GetAssembly(GetType()));
11+
12+
foreach (var buildServer in buildServers)
13+
{
14+
services.AddSingleton(typeof(IBuildServer), buildServer);
15+
}
16+
}
17+
}
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Microsoft.Extensions.DependencyInjection;
6+
7+
namespace GitVersion
8+
{
9+
public abstract class GitVersionModule : IGitVersionModule
10+
{
11+
public abstract void RegisterTypes(IServiceCollection services);
12+
13+
protected static IEnumerable<Type> FindAllDerivedTypes<T>(Assembly assembly)
14+
{
15+
var derivedType = typeof(T);
16+
return assembly.GetTypes().Where(t => t != derivedType && derivedType.IsAssignableFrom(t));
17+
}
18+
}
19+
}
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
41
using System.Reflection;
52
using GitVersion.Configuration.Init.Wizard;
63
using Microsoft.Extensions.DependencyInjection;
74

85
namespace GitVersion.Configuration.Init
96
{
10-
public class GitVersionInitModule : IGitVersionModule
7+
public class GitVersionInitModule : GitVersionModule
118
{
12-
public void RegisterTypes(IServiceCollection services)
9+
public override void RegisterTypes(IServiceCollection services)
1310
{
1411
services.AddTransient<IConfigInitWizard, ConfigInitWizard>();
1512
services.AddTransient<IConfigInitStepFactory, ConfigInitStepFactory>();
@@ -21,11 +18,5 @@ public void RegisterTypes(IServiceCollection services)
2118
services.AddTransient(step);
2219
}
2320
}
24-
25-
private static IEnumerable<Type> FindAllDerivedTypes<T>(Assembly assembly)
26-
{
27-
var derivedType = typeof(T);
28-
return assembly.GetTypes().Where(t => t != derivedType && derivedType.IsAssignableFrom(t));
29-
}
3021
}
3122
}

0 commit comments

Comments
 (0)