Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4a9fa96
Add Microsoft.Extensions.DependencyInjection
arturcic Oct 17, 2019
ff811ea
Add Microsoft.Extensions.Hosting
arturcic Oct 17, 2019
83d002a
Register types in each module
arturcic Oct 20, 2019
8895c6c
refactored ExecCommand and ExecuteCore
arturcic Oct 21, 2019
f3ac0e9
replaced BuildServerList with BuildServerResolver
arturcic Oct 21, 2019
26480d7
moved initialization to CoreModule
arturcic Oct 21, 2019
923f91d
applied code review changes
arturcic Oct 22, 2019
dd892d5
using c#8 using declarations
arturcic Oct 22, 2019
dbac722
code cleanup for GitVersionComputer & GitPrepare
arturcic Oct 22, 2019
df2f486
code cleanup for GitPrepare
arturcic Oct 22, 2019
d7d0dc5
moved the semanticversion classes to folder, made IGitVersionCache DI
arturcic Oct 22, 2019
ec1639e
applied code review changes
arturcic Oct 23, 2019
fb2566f
moving to DI GitVersionFinder, VariableProvider and MetaDataCalculator
arturcic Oct 23, 2019
8e0c12d
moving to DI ConfigurationProvider, GitPreparer
arturcic Oct 23, 2019
d040f41
made GitversionTask DI aware
arturcic Oct 23, 2019
ce1e815
migrate to DI IBaseVersionCalculator
arturcic Oct 23, 2019
9dcce02
migrate to DI NextVersionCalculator
arturcic Oct 23, 2019
901cccc
code cleanup
arturcic Oct 23, 2019
5958435
applied code review changes
arturcic Oct 24, 2019
82a8e33
made GitversionTask DI aware, added GitVersionTaskExecutor
arturcic Oct 24, 2019
433a597
ConfigurationProvider cleanup
arturcic Oct 24, 2019
d572cc7
moving to DI MainlineVersionCalculator
arturcic Oct 24, 2019
dff4e62
using c#8 switch expressions
arturcic Oct 24, 2019
b394a93
moving to DI ConfigInit
arturcic Oct 24, 2019
b243b4d
ConfigInitSteps, made constructor with the same parameters
arturcic Oct 24, 2019
cd1afb1
moving to DI ConfigInit (2), added IConfigInitStepFactory
arturcic Oct 24, 2019
a22fb34
added "?? throw new ArgumentNullException(nameof({field}))" to the i…
arturcic Oct 24, 2019
405cdb3
fix GitPrepare injection
arturcic Oct 24, 2019
ba517dd
moved ConfigInit registration from CoreModule
arturcic Oct 24, 2019
70cb999
introduced ConfigFileLocatorFactory
arturcic Oct 24, 2019
98eebe6
adjusted field names, removed underscore
arturcic Oct 25, 2019
2684c41
code review adjustments
arturcic Oct 25, 2019
7ef3499
code review adjustments
arturcic Oct 25, 2019
02074ed
Moved the `GitVersionTask` and `GitVersionTask.MsBuild` under `GitVer…
arturcic Oct 25, 2019
83ed431
+semver: minor code review adjustments
arturcic Oct 25, 2019
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
Prev Previous commit
Next Next commit
added "?? throw new ArgumentNullException(nameof({field}))" to the in…
…jected arguments
  • Loading branch information
arturcic committed Oct 24, 2019
commit a22fb34e3d6566fa9e859fed33a5a1a7d7f15405
4 changes: 2 additions & 2 deletions src/GitVersionCore/Cache/GitVersionCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class GitVersionCache : IGitVersionCache

public GitVersionCache(IFileSystem fileSystem, ILog log)
{
this.fileSystem = fileSystem;
this.log = log;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.log = log ?? throw new ArgumentNullException(nameof(log));
}

public void WriteVariablesToDiskCache(IGitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BranchConfigurationCalculator : IBranchConfigurationCalculator

public BranchConfigurationCalculator(ILog log, GitVersionContext context)
{
this.log = log;
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.context = context;
}

Expand Down
5 changes: 3 additions & 2 deletions src/GitVersionCore/Configuration/ConfigFileLocator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using GitVersion.Logging;

Expand All @@ -10,8 +11,8 @@ public abstract class ConfigFileLocator : IConfigFileLocator

protected ConfigFileLocator(IFileSystem fileSystem, ILog log)
{
FileSystem = fileSystem;
Log = log;
FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
Log = log ?? throw new ArgumentNullException(nameof(log));
}

public abstract bool HasConfigFileAt(string workingDirectory);
Expand Down
11 changes: 6 additions & 5 deletions src/GitVersionCore/Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Text;
using GitVersion.Configuration.Init.Wizard;
Expand All @@ -15,11 +16,11 @@ public class ConfigurationProvider : IConfigurationProvider

public ConfigurationProvider(IFileSystem fileSystem, ILog log, IConfigFileLocator configFileLocator, IGitPreparer gitPreparer, IConfigInitWizard configInitWizard)
{
this.fileSystem = fileSystem;
this.log = log;
this.configFileLocator = configFileLocator;
this.gitPreparer = gitPreparer;
this.configInitWizard = configInitWizard;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
this.gitPreparer = gitPreparer ?? throw new ArgumentNullException(nameof(gitPreparer));
this.configInitWizard = configInitWizard ?? throw new ArgumentNullException(nameof(this.configInitWizard));
}

public Config Provide(bool applyDefaults = true, Config overrideConfig = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ConfigInitStepFactory()

public ConfigInitStepFactory(IServiceProvider sp)
{
this.sp = sp;
this.sp = sp ?? throw new ArgumentNullException(nameof(sp));
}

public T CreateStep<T>() => sp.GetService<T>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;

namespace GitVersion.Configuration.Init.Wizard
Expand All @@ -9,8 +10,8 @@ public class ConfigInitWizard : IConfigInitWizard

public ConfigInitWizard(IConsole console, IConfigInitStepFactory stepFactory)
{
this.console = console;
this.stepFactory = stepFactory;
this.console = console ?? throw new ArgumentNullException(nameof(console));
this.stepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
}

public Config Run(Config config, string workingDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public abstract class ConfigInitWizardStep

protected ConfigInitWizardStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory)
{
Console = console;
FileSystem = fileSystem;
Log = log;
StepFactory = stepFactory;
Console = console ?? throw new ArgumentNullException(nameof(console));
FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
Log = log ?? throw new ArgumentNullException(nameof(log));
StepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
}

public bool Apply(Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersionCore/Extensions/WixVersionFileUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class WixVersionFileUpdater : IDisposable
public WixVersionFileUpdater(string workingDirectory, VersionVariables variables, IFileSystem fileSystem, ILog log)
{
this.variables = variables;
this.fileSystem = fileSystem;
this.log = log;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.WixVersionFile = Path.Combine(workingDirectory, WIX_VERSION_FILE);
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/GitPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GitPreparer : IGitPreparer

public GitPreparer(ILog log, Arguments arguments)
{
this.log = log;
this.log = log ?? throw new ArgumentNullException(nameof(log));

TargetUrl = arguments.TargetUrl;
WorkingDirectory = arguments.TargetPath.TrimEnd('/', '\\');
Expand Down
18 changes: 9 additions & 9 deletions src/GitVersionCore/GitVersionCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public GitVersionCalculator(IFileSystem fileSystem, ILog log, IConfigFileLocator
IBuildServerResolver buildServerResolver, IGitVersionCache gitVersionCache,
IGitVersionFinder gitVersionFinder, IGitPreparer gitPreparer, IVariableProvider variableProvider, IOptions<Arguments> options)
{
this.fileSystem = fileSystem;
this.log = log;
this.configFileLocator = configFileLocator;
this.configurationProvider = configurationProvider;
this.buildServerResolver = buildServerResolver;
this.gitVersionCache = gitVersionCache;
this.gitVersionFinder = gitVersionFinder;
this.gitPreparer = gitPreparer;
this.variableProvider = variableProvider;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
this.configurationProvider = configurationProvider ?? throw new ArgumentNullException(nameof(configurationProvider));
this.buildServerResolver = buildServerResolver ?? throw new ArgumentNullException(nameof(buildServerResolver));
this.gitVersionCache = gitVersionCache ?? throw new ArgumentNullException(nameof(gitVersionCache));
this.gitVersionFinder = gitVersionFinder ?? throw new ArgumentNullException(nameof(gitVersionFinder));
this.gitPreparer = gitPreparer ?? throw new ArgumentNullException(nameof(gitPreparer));
this.variableProvider = variableProvider ?? throw new ArgumentNullException(nameof(variableProvider));
this.arguments = options.Value;
}

Expand Down
5 changes: 3 additions & 2 deletions src/GitVersionCore/GitVersionFinder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using GitVersion.Exceptions;
using GitVersion.VersionCalculation;
Expand All @@ -14,8 +15,8 @@ public class GitVersionFinder : IGitVersionFinder

public GitVersionFinder(ILog log, INextVersionCalculator nextVersionCalculator)
{
this.log = log;
this.nextVersionCalculator = nextVersionCalculator;
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.nextVersionCalculator = nextVersionCalculator ?? throw new ArgumentNullException(nameof(nextVersionCalculator));
}

public SemanticVersion FindVersion(GitVersionContext context)
Expand Down
3 changes: 0 additions & 3 deletions src/GitVersionCore/IncrementStrategyFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public static class IncrementStrategyFinder
return null;
}



private static IEnumerable<Commit> GetIntermediateCommits(IRepository repo, Commit baseCommit, Commit headCommit)
{
if (baseCommit == null) yield break;
Expand Down Expand Up @@ -131,7 +129,6 @@ private static IEnumerable<Commit> GetIntermediateCommits(IRepository repo, Comm
return version;
}


private static VersionField? FindIncrementFromMessage(string message, string majorRegex, string minorRegex, string patchRegex, string noneRegex)
{
if(IsMatch(message, majorRegex)) return VersionField.Major;
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/OutputVariables/VariableProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class VariableProvider : IVariableProvider

public VariableProvider(INextVersionCalculator nextVersionCalculator)
{
this.nextVersionCalculator = nextVersionCalculator;
this.nextVersionCalculator = nextVersionCalculator ?? throw new ArgumentNullException(nameof(nextVersionCalculator));
}

public VersionVariables GetVariablesFor(SemanticVersion semanticVersion, EffectiveConfiguration config, bool isCurrentCommitTagged)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BaseVersionCalculator : IBaseVersionCalculator

public BaseVersionCalculator(ILog log, IEnumerable<IVersionStrategy> strategies)
{
this.log = log;
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.strategies = strategies?.ToArray() ?? Array.Empty<IVersionStrategy>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ internal class MainlineVersionCalculator : IMainlineVersionCalculator

public MainlineVersionCalculator(ILog log, IMetaDataCalculator metaDataCalculator)
{
this.metaDataCalculator = metaDataCalculator;
this.log = log;
this.metaDataCalculator = metaDataCalculator ?? throw new ArgumentNullException(nameof(metaDataCalculator));
this.log = log ?? throw new ArgumentNullException(nameof(log));
}

public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion, GitVersionContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using GitVersion.VersionCalculation.BaseVersionCalculators;
Expand All @@ -18,11 +19,11 @@ public class NextVersionCalculator : INextVersionCalculator

public NextVersionCalculator(ILog log, IMetaDataCalculator metaDataCalculator, IBaseVersionCalculator baseVersionCalculator, IMainlineVersionCalculator mainlineVersionCalculator)
{
this.log = log;
this.metaDataCalculator = metaDataCalculator;
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.metaDataCalculator = metaDataCalculator ?? throw new ArgumentNullException(nameof(metaDataCalculator));

this.baseVersionCalculator = baseVersionCalculator;
this.mainlineVersionCalculator = mainlineVersionCalculator;
this.baseVersionCalculator = baseVersionCalculator ?? throw new ArgumentNullException(nameof(baseVersionCalculator));
this.mainlineVersionCalculator = mainlineVersionCalculator ?? throw new ArgumentNullException(nameof(mainlineVersionCalculator));
}

public SemanticVersion FindVersion(GitVersionContext context)
Expand Down
8 changes: 4 additions & 4 deletions src/GitVersionExe/ExecCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class ExecCommand : IExecCommand

public ExecCommand(IFileSystem fileSystem, IBuildServerResolver buildServerResolver, ILog log, IGitVersionCalculator gitVersionCalculator, IOptions<Arguments> arguments)
{
this.fileSystem = fileSystem;
this.buildServerResolver = buildServerResolver;
this.log = log;
this.gitVersionCalculator = gitVersionCalculator;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.buildServerResolver = buildServerResolver ?? throw new ArgumentNullException(nameof(buildServerResolver));
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.gitVersionCalculator = gitVersionCalculator ?? throw new ArgumentNullException(nameof(gitVersionCalculator));
this.arguments = arguments.Value;
}

Expand Down
4 changes: 2 additions & 2 deletions src/GitVersionExe/GitVersionApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ internal class GitVersionApp : IHostedService
public GitVersionApp(IHostApplicationLifetime applicationLifetime, IGitVersionExecutor gitVersionExecutor, ILog log, IOptions<Arguments> options)
{
this.arguments = options.Value;
this.applicationLifetime = applicationLifetime;
this.gitVersionExecutor = gitVersionExecutor;
this.applicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime));
this.gitVersionExecutor = gitVersionExecutor ?? throw new ArgumentNullException(nameof(gitVersionExecutor));

log.Verbosity = arguments.Verbosity;
}
Expand Down
14 changes: 7 additions & 7 deletions src/GitVersionExe/GitVersionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class GitVersionExecutor : IGitVersionExecutor
public GitVersionExecutor(ILog log, IConfigFileLocator configFileLocator, IVersionWriter versionWriter, IHelpWriter helpWriter,
IExecCommand execCommand, IConfigurationProvider configurationProvider, IBuildServerResolver buildServerResolver)
{
this.log = log;
this.configFileLocator = configFileLocator;
this.versionWriter = versionWriter;
this.helpWriter = helpWriter;
this.execCommand = execCommand;
this.configurationProvider = configurationProvider;
this.buildServerResolver = buildServerResolver;
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
this.versionWriter = versionWriter ?? throw new ArgumentNullException(nameof(versionWriter));
this.helpWriter = helpWriter ?? throw new ArgumentNullException(nameof(helpWriter));
this.execCommand = execCommand ?? throw new ArgumentNullException(nameof(execCommand));
this.configurationProvider = configurationProvider ?? throw new ArgumentNullException(nameof(configFileLocator));
this.buildServerResolver = buildServerResolver ?? throw new ArgumentNullException(nameof(buildServerResolver));
}

public int Execute(Arguments arguments)
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionExe/HelpWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class HelpWriter : IHelpWriter

public HelpWriter(IVersionWriter versionWriter)
{
this.versionWriter = versionWriter;
this.versionWriter = versionWriter ?? throw new ArgumentNullException(nameof(versionWriter));
}

public void Write()
Expand Down
9 changes: 5 additions & 4 deletions src/GitVersionTask/GitVersionTaskExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using GitVersion;
using GitVersion.Extensions.GitVersionInformationResources;
Expand All @@ -17,10 +18,10 @@ public class GitVersionTaskExecutor : IGitVersionTaskExecutor

public GitVersionTaskExecutor(IFileSystem fileSystem, ILog log, IBuildServerResolver buildServerResolver, IGitVersionCalculator gitVersionCalculator)
{
this.fileSystem = fileSystem;
this.log = log;
this.buildServerResolver = buildServerResolver;
this.gitVersionCalculator = gitVersionCalculator;
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
this.log = log ?? throw new ArgumentNullException(nameof(log));
this.buildServerResolver = buildServerResolver ?? throw new ArgumentNullException(nameof(buildServerResolver));
this.gitVersionCalculator = gitVersionCalculator ?? throw new ArgumentNullException(nameof(gitVersionCalculator));
}

public void GetVersion(GetVersion task)
Expand Down