diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 7ac3dde2dc..56966c42d8 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -45,6 +45,7 @@ * TrackReleaseBranches * VersionInBranchName * TrunkBased +* The initialization wizard has been removed. ## v5.0.0 diff --git a/src/GitVersion.App.Tests/HelpWriterTests.cs b/src/GitVersion.App.Tests/HelpWriterTests.cs index df75c5510a..714b08c1f7 100644 --- a/src/GitVersion.App.Tests/HelpWriterTests.cs +++ b/src/GitVersion.App.Tests/HelpWriterTests.cs @@ -20,7 +20,6 @@ public void AllArgsAreInHelp() var lookup = new Dictionary { { nameof(Arguments.TargetUrl), "/url" }, - { nameof(Arguments.Init), "init" }, { nameof(Arguments.TargetBranch), "/b" }, { nameof(Arguments.LogFilePath) , "/l" }, { nameof(Arguments.OutputFile) , "/outputfile" }, diff --git a/src/GitVersion.App/ArgumentParser.cs b/src/GitVersion.App/ArgumentParser.cs index 68675bc261..781d431574 100644 --- a/src/GitVersion.App/ArgumentParser.cs +++ b/src/GitVersion.App/ArgumentParser.cs @@ -44,15 +44,6 @@ public Arguments ParseArguments(string[] commandLineArguments) var firstArgument = commandLineArguments[0]; - if (firstArgument.IsInit()) - { - return new Arguments - { - TargetPath = SysEnv.CurrentDirectory, - Init = true - }; - } - if (firstArgument.IsHelp()) { return new Arguments diff --git a/src/GitVersion.App/Arguments.cs b/src/GitVersion.App/Arguments.cs index 0680e196e5..03e7714b9d 100644 --- a/src/GitVersion.App/Arguments.cs +++ b/src/GitVersion.App/Arguments.cs @@ -19,7 +19,6 @@ internal class Arguments public string? CommitId; public string? ClonePath; - public bool Init; public bool Diag; public bool IsVersion; public bool IsHelp; @@ -86,7 +85,6 @@ public GitVersionOptions ToOptions() UpdateWixVersionFile = UpdateWixVersionFile }, - Init = Init, Diag = Diag, IsVersion = IsVersion, IsHelp = IsHelp, diff --git a/src/GitVersion.App/GitVersionExecutor.cs b/src/GitVersion.App/GitVersionExecutor.cs index 6c3052e989..0ff21108a9 100644 --- a/src/GitVersion.App/GitVersionExecutor.cs +++ b/src/GitVersion.App/GitVersionExecutor.cs @@ -136,13 +136,6 @@ private bool HandleNonMainCommand(GitVersionOptions gitVersionOptions, out int e this.log.Info("Working directory: " + workingDirectory); } - if (gitVersionOptions.Init) - { - this.configurationProvider.Init(workingDirectory); - exitCode = 0; - return true; - } - if (gitVersionOptions.ConfigurationInfo.ShowConfiguration) { if (gitVersionOptions.RepositoryInfo.TargetUrl.IsNullOrWhiteSpace()) @@ -161,7 +154,7 @@ private bool HandleNonMainCommand(GitVersionOptions gitVersionOptions, out int e private static void ConfigureLogging(GitVersionOptions gitVersionOptions, ILog log) { - if (gitVersionOptions.Output.Contains(OutputType.BuildServer) || gitVersionOptions.LogFilePath == "console" || gitVersionOptions.Init) + if (gitVersionOptions.Output.Contains(OutputType.BuildServer) || gitVersionOptions.LogFilePath == "console") { log.AddLogAppender(new ConsoleAppender()); } diff --git a/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.CanSetNextVersion.approved.txt b/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.CanSetNextVersion.approved.txt deleted file mode 100644 index 32913c39f0..0000000000 --- a/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.CanSetNextVersion.approved.txt +++ /dev/null @@ -1,11 +0,0 @@ -next-version: 2.0.0 -merge-message-formats: {} -update-build-number: true -semantic-version-format: Strict -strategies: [] -branches: {} -ignore: - sha: [] -increment: None -source-branches: [] -is-source-branch-for: [] diff --git a/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.cs b/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.cs deleted file mode 100644 index 47b2d17dd3..0000000000 --- a/src/GitVersion.Configuration.Tests/Configuration/Init/InitScenarios.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Runtime.InteropServices; -using GitVersion.Configuration; -using GitVersion.Core.Tests.Helpers; -using GitVersion.Helpers; -using GitVersion.Logging; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; - -namespace GitVersion.Core.Tests.Init; - -[TestFixture] -public class InitScenarios : TestBase -{ - [SetUp] - public void Setup() => ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute(); - - [Test] - public void CanSetNextVersion() - { - var workingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj"; - var options = Options.Create(new GitVersionOptions { WorkingDirectory = workingDirectory }); - - var sp = ConfigureServices(services => - { - services.AddSingleton(new TestConsole("3", "2.0.0", "0")); - services.AddSingleton(options); - }); - - var configurationProvider = sp.GetRequiredService(); - var fileSystem = sp.GetRequiredService(); - configurationProvider.Init(workingDirectory); - - var configFile = PathHelper.Combine(workingDirectory, ConfigurationFileLocator.DefaultFileName); - fileSystem.ReadAllText(configFile).ShouldMatchApproved(); - } -} diff --git a/src/GitVersion.Configuration/ConfigurationProvider.cs b/src/GitVersion.Configuration/ConfigurationProvider.cs index cfab0bbd92..aa4920a6b9 100644 --- a/src/GitVersion.Configuration/ConfigurationProvider.cs +++ b/src/GitVersion.Configuration/ConfigurationProvider.cs @@ -1,7 +1,5 @@ -using GitVersion.Configuration.Init.Wizard; using GitVersion.Configuration.SupportedWorkflows; using GitVersion.Extensions; -using GitVersion.Helpers; using GitVersion.Logging; using Microsoft.Extensions.Options; using YamlDotNet.Core; @@ -12,15 +10,13 @@ internal class ConfigurationProvider( IFileSystem fileSystem, ILog log, IConfigurationFileLocator configFileLocator, - IOptions options, - IConfigInitWizard configInitWizard) + IOptions options) : IConfigurationProvider { private readonly IFileSystem fileSystem = fileSystem.NotNull(); private readonly ILog log = log.NotNull(); private readonly IConfigurationFileLocator configFileLocator = configFileLocator.NotNull(); private readonly IOptions options = options.NotNull(); - private readonly IConfigInitWizard configInitWizard = configInitWizard.NotNull(); public IGitVersionConfiguration Provide(IReadOnlyDictionary? overrideConfiguration) { @@ -33,23 +29,6 @@ public IGitVersionConfiguration Provide(IReadOnlyDictionary? ov : ProvideForDirectory(null, overrideConfiguration); } - public void Init(string workingDirectory) - { - var gitVersionOptions = this.options.Value; - var fileName = gitVersionOptions.ConfigurationInfo.ConfigurationFile ?? ConfigurationFileLocator.DefaultFileName; - var configFilePath = PathHelper.Combine(workingDirectory, fileName); - var currentConfiguration = this.configFileLocator.ReadConfiguration(configFilePath); - - var configuration = this.configInitWizard.Run(currentConfiguration, workingDirectory); - if (configuration == null) return; - - using var stream = this.fileSystem.OpenWrite(configFilePath); - using var writer = new StreamWriter(stream); - this.log.Info("Saving configuration file"); - ConfigurationSerializer.Write(configuration, writer); - stream.Flush(); - } - internal IGitVersionConfiguration ProvideForDirectory(string? workingDirectory, IReadOnlyDictionary? overrideConfiguration = null) { diff --git a/src/GitVersion.Configuration/GitVersionConfigurationModule.cs b/src/GitVersion.Configuration/GitVersionConfigurationModule.cs index f710fc6465..b8c8cae713 100644 --- a/src/GitVersion.Configuration/GitVersionConfigurationModule.cs +++ b/src/GitVersion.Configuration/GitVersionConfigurationModule.cs @@ -1,5 +1,3 @@ -using GitVersion.Configuration.Init; -using GitVersion.Extensions; using GitVersion.VersionCalculation.Caching; using Microsoft.Extensions.DependencyInjection; @@ -9,8 +7,6 @@ public class GitVersionConfigurationModule : IGitVersionModule { public void RegisterTypes(IServiceCollection services) { - services.AddModule(new GitVersionInitModule()); - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/src/GitVersion.Configuration/Init/BuildServer/AppVeyorSetup.cs b/src/GitVersion.Configuration/Init/BuildServer/AppVeyorSetup.cs deleted file mode 100644 index 787b7c70e8..0000000000 --- a/src/GitVersion.Configuration/Init/BuildServer/AppVeyorSetup.cs +++ /dev/null @@ -1,123 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Helpers; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.BuildServer; - -internal class AppVeyorSetup(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - private ProjectVisibility projectVisibility; - - public AppVeyorSetup WithData(ProjectVisibility visibility) - { - this.projectVisibility = visibility; - return this; - } - - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var editConfigStep = this.StepFactory.CreateStep(); - switch (result) - { - case "0": - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "1": - GenerateBasicConfig(workingDirectory); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "2": - GenerateNuGetConfig(workingDirectory); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - } - return StepResult.InvalidResponseSelected(); - } - - private static string GetGvCommand(ProjectVisibility visibility) => visibility switch - { - ProjectVisibility.Public => " - ps: gitversion /l console /output buildserver /updateAssemblyInfo", - ProjectVisibility.Private => " - ps: gitversion $env:APPVEYOR_BUILD_FOLDER /l console /output buildserver /updateAssemblyInfo /nofetch /b $env:APPVEYOR_REPO_BRANCH", - _ => "" - }; - - private void GenerateBasicConfig(string workingDirectory) => WriteConfig(workingDirectory, this.FileSystem, $@"install: - - choco install gitversion.portable -pre -y - -before_build: - - nuget restore -{GetGvCommand(this.projectVisibility)} - -build: - project: "); - - private void GenerateNuGetConfig(string workingDirectory) => WriteConfig(workingDirectory, this.FileSystem, $@"install: - - choco install gitversion.portable -pre -y - -assembly_info: - patch: false - -before_build: - - nuget restore -{GetGvCommand(this.projectVisibility)} - -build: - project: - -after_build: - - cmd: ECHO nuget pack \.nuspec -version ""%GitVersion_NuGetVersion%"" -prop ""target=%CONFIGURATION%"" - - cmd: nuget pack \.nuspec -version ""%GitVersion_NuGetVersion%"" -prop ""target=%CONFIGURATION%"" - - cmd: appveyor PushArtifact "".%GitVersion_NuGetVersion%.nupkg"""); - - private void WriteConfig(string workingDirectory, IFileSystem fileSystem, string configContents) - { - var outputFilename = GetOutputFilename(workingDirectory, fileSystem); - fileSystem.WriteAllText(outputFilename, configContents); - this.Log.Info($"AppVeyor sample configuration file written to {outputFilename}"); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var prompt = new StringBuilder(); - if (AppVeyorConfigExists(workingDirectory, this.FileSystem)) - { - prompt.AppendLine("GitVersion doesn't support modifying existing appveyor configuration files. We will generate appveyor.gitversion.yml instead"); - prompt.AppendLine(); - } - - prompt.Append(@"What sort of configuration template would you like generated? - -0) Go Back -1) Generate basic (gitversion + msbuild) configuration -2) Generate with NuGet package publish"); - - return prompt.ToString(); - } - - private static string GetOutputFilename(string workingDirectory, IFileSystem fileSystem) - { - if (AppVeyorConfigExists(workingDirectory, fileSystem)) - { - var count = 0; - do - { - var path = PathHelper.Combine(workingDirectory, $"appveyor.gitversion{(count == 0 ? string.Empty : "." + count)}.yml"); - - if (!fileSystem.Exists(path)) - { - return path; - } - - count++; - } while (count < 10); - throw new Exception("appveyor.gitversion.yml -> appveyor.gitversion.9.yml all exist. Pretty sure you have enough templates"); - } - - return PathHelper.Combine(workingDirectory, "appveyor.yml"); - } - - private static bool AppVeyorConfigExists(string workingDirectory, IFileSystem fileSystem) => fileSystem.Exists(PathHelper.Combine(workingDirectory, "appveyor.yml")); - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/BuildServer/AppveyorPublicPrivate.cs b/src/GitVersion.Configuration/Init/BuildServer/AppveyorPublicPrivate.cs deleted file mode 100644 index 514d0dd6f4..0000000000 --- a/src/GitVersion.Configuration/Init/BuildServer/AppveyorPublicPrivate.cs +++ /dev/null @@ -1,35 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.BuildServer; - -internal class AppveyorPublicPrivate(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result) - { - case "0": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "1": - steps.Enqueue(this.StepFactory.CreateStep().WithData(ProjectVisibility.Public)); - return StepResult.Ok(); - case "2": - steps.Enqueue(this.StepFactory.CreateStep().WithData(ProjectVisibility.Private)); - return StepResult.Ok(); - } - return StepResult.Ok(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"Is your project public or private? - -That is ... does it require authentication to clone/pull? - -0) Go Back -1) Public -2) Private"; - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/BuildServer/ProjectVisibility.cs b/src/GitVersion.Configuration/Init/BuildServer/ProjectVisibility.cs deleted file mode 100644 index 06c6b8d64f..0000000000 --- a/src/GitVersion.Configuration/Init/BuildServer/ProjectVisibility.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace GitVersion.Configuration.Init.BuildServer; - -internal enum ProjectVisibility -{ - Public = 0, - Private = 1 -} diff --git a/src/GitVersion.Configuration/Init/BuildServer/SetupBuildScripts.cs b/src/GitVersion.Configuration/Init/BuildServer/SetupBuildScripts.cs deleted file mode 100644 index dc7d461be8..0000000000 --- a/src/GitVersion.Configuration/Init/BuildServer/SetupBuildScripts.cs +++ /dev/null @@ -1,31 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.BuildServer; - -internal class SetupBuildScripts(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result) - { - case "0": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "1": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - return StepResult.Ok(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"What build server are you using? - -Want to see more? Contribute a pull request! - -0) Go Back -1) AppVeyor"; - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/EditConfigStep.cs b/src/GitVersion.Configuration/Init/EditConfigStep.cs deleted file mode 100644 index 786b7eefb0..0000000000 --- a/src/GitVersion.Configuration/Init/EditConfigStep.cs +++ /dev/null @@ -1,64 +0,0 @@ -using GitVersion.Configuration.Init.BuildServer; -using GitVersion.Configuration.Init.SetConfig; -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; -using GitVersion.VersionCalculation; - -namespace GitVersion.Configuration.Init; - -internal class EditConfigStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result) - { - case "0": - return StepResult.SaveAndExit(); - case "1": - return StepResult.ExitWithoutSaving(); - - case "2": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - - case "3": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - - case "4": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "5": - var editConfigStep = this.StepFactory.CreateStep(); - steps.Enqueue(this.StepFactory.CreateStep().WithData(editConfigStep, false)); - return StepResult.Ok(); - case "6": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "7": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var configuration = configurationBuilder.Build(); - return $@"Which would you like to change? - -0) Save changes and exit -1) Exit without saving - -2) Run getting started wizard - -3) Set next version number -4) Branch specific configuration -5) Branch Increment mode (per commit/after tag) (Current: {configuration.DeploymentMode ?? DeploymentMode.ContinuousDeployment}) -6) Assembly versioning scheme (Current: {configuration.AssemblyVersioningScheme}) -7) Setup build scripts"; - } - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/Init/GitVersionInitModule.cs b/src/GitVersion.Configuration/Init/GitVersionInitModule.cs deleted file mode 100644 index 048d81c233..0000000000 --- a/src/GitVersion.Configuration/Init/GitVersionInitModule.cs +++ /dev/null @@ -1,20 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using Microsoft.Extensions.DependencyInjection; - -namespace GitVersion.Configuration.Init; - -public class GitVersionInitModule : IGitVersionModule -{ - public void RegisterTypes(IServiceCollection services) - { - services.AddTransient(); - services.AddTransient(); - - var steps = IGitVersionModule.FindAllDerivedTypes(Assembly.GetAssembly(GetType())); - - foreach (var step in steps) - { - services.AddTransient(step); - } - } -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/AssemblyVersioningSchemeSetting.cs b/src/GitVersion.Configuration/Init/SetConfig/AssemblyVersioningSchemeSetting.cs deleted file mode 100644 index bb0070ee1d..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/AssemblyVersioningSchemeSetting.cs +++ /dev/null @@ -1,53 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Extensions; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class AssemblyVersioningSchemeSetting(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var editConfigStep = this.StepFactory.CreateStep(); - switch (result) - { - case "0": - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "1": - configurationBuilder.WithAssemblyVersioningScheme(AssemblyVersioningScheme.Major); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "2": - configurationBuilder.WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinor); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "3": - configurationBuilder.WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatch); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "4": - configurationBuilder.WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatchTag); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - case "5": - configurationBuilder.WithAssemblyVersioningScheme(AssemblyVersioningScheme.None); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"What assembly versioning scheme do you want to use: - -0) Go Back -1) Major.0.0.0 -2) Major.Minor.0.0 -3) Major.Minor.Patch.0 (default) -4) Major.Minor.Patch.TagCount (Allows different pre-release tags to cause assembly version to change) -5) None (skip's updating AssemblyVersion)"; - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranch.cs b/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranch.cs deleted file mode 100644 index 211ed15380..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class ConfigureBranch(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - private string name; - private BranchConfigurationBuilder branchConfigurationBuilder; - - public ConfigureBranch WithData(string configName, BranchConfigurationBuilder configurationBuilder) - { - this.branchConfigurationBuilder = configurationBuilder; - this.name = configName; - return this; - } - - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result) - { - case "0": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "1": - steps.Enqueue(this.StepFactory.CreateStep().WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - case "2": - steps.Enqueue(this.StepFactory.CreateStep().WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var branchConfiguration = this.branchConfigurationBuilder.Build(); - return $@"What would you like to change for '{this.name}': - -0) Go Back -1) Branch Pr-release tag (Current: {branchConfiguration.Label}) -2) Branch Increment mode (per commit/after tag) (Current: {branchConfiguration.DeploymentMode})"; - } - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranches.cs b/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranches.cs deleted file mode 100644 index 628c56ce0c..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/ConfigureBranches.cs +++ /dev/null @@ -1,58 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Helpers; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class ConfigureBranches(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - if (int.TryParse(result, out var parsed)) - { - if (parsed == 0) - { - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - - try - { - var configuration = configurationBuilder.Build(); - var (name, branchConfiguration) = OrderedBranches(configuration).ElementAt(parsed - 1); - var branchConfigurationBuilder = BranchConfigurationBuilder.New.WithConfiguration(branchConfiguration); - configurationBuilder.WithBranch(name, branchConfigurationBuilder); - steps.Enqueue(this.StepFactory.CreateStep().WithData(name, branchConfigurationBuilder)); - return StepResult.Ok(); - } - catch (ArgumentOutOfRangeException) - { } - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var configuration = configurationBuilder.Build(); - return @"Which branch would you like to configure: - -0) Go Back -" + string.Join(PathHelper.NewLine, OrderedBranches(configuration).Select((c, i) => $"{i + 1}) {c.Key}")); - } - - private static IOrderedEnumerable> OrderedBranches(IGitVersionConfiguration configuration) - { - var defaultConfig = GitFlowConfigurationBuilder.New.Build(); - - var configurationBranches = configuration.Branches; - var defaultConfigurationBranches = defaultConfig.Branches - .Where(k => !configurationBranches.ContainsKey(k.Key)) - // Return an empty branch configuration - .Select(v => new KeyValuePair(v.Key, new BranchConfiguration())); - return configurationBranches.Union(defaultConfigurationBranches).OrderBy(b => b.Key); - } - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs b/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs deleted file mode 100644 index 79e954b0f5..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs +++ /dev/null @@ -1,54 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; -using GitVersion.VersionCalculation; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class GlobalModeSetting(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - private ConfigInitWizardStep returnToStep; - private bool isPartOfWizard; - - public GlobalModeSetting WithData(ConfigInitWizardStep returnStep, bool isPartOfTheWizard) - { - this.returnToStep = returnStep; - this.isPartOfWizard = isPartOfTheWizard; - return this; - } - - protected override StepResult HandleResult( - string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result) - { - case "1": - configurationBuilder.WithDeploymentMode(DeploymentMode.ManualDeployment); - steps.Enqueue(this.returnToStep); - return StepResult.Ok(); - case "2": - configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDelivery); - steps.Enqueue(this.returnToStep); - return StepResult.Ok(); - case "3": - configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDeployment); - steps.Enqueue(this.returnToStep); - return StepResult.Ok(); - case "0": - case "4": - steps.Enqueue(this.returnToStep); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => $@"What do you want the default increment mode to be (can be override per branch): -{(!this.isPartOfWizard ? "0) Go Back" : string.Empty)} -1) Follow SemVer and only increment when a release has been tagged (continuous delivery mode) -2) Increment based on branch configuration every commit (continuous deployment mode) -3) Each merged branch against main will increment the version (mainline mode) -{(this.isPartOfWizard ? "4) Skip" : string.Empty)}"; - - protected override string DefaultResult => "4"; -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/SetBranchIncrementMode.cs b/src/GitVersion.Configuration/Init/SetConfig/SetBranchIncrementMode.cs deleted file mode 100644 index 6c2c31d599..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/SetBranchIncrementMode.cs +++ /dev/null @@ -1,48 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Logging; -using GitVersion.VersionCalculation; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class SetBranchIncrementMode(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - private string name; - private BranchConfigurationBuilder branchConfigurationBuilder; - - public SetBranchIncrementMode WithData(string configName, BranchConfigurationBuilder configurationBuilder) - { - this.branchConfigurationBuilder = configurationBuilder; - this.name = configName; - return this; - } - - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var configureBranchStep = this.StepFactory.CreateStep(); - switch (result) - { - case "0": - steps.Enqueue(configureBranchStep.WithData(this.name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - case "1": - this.branchConfigurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDelivery); - steps.Enqueue(configureBranchStep.WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - case "2": - this.branchConfigurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDeployment); - steps.Enqueue(configureBranchStep.WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => $@"What do you want the increment mode for {this.name} to be? - -0) Go Back -1) Follow SemVer and only increment when a release has been tagged (continuous delivery mode) -2) Increment based on branch configuration every commit (continuous deployment mode)"; - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/SetConfig/SetBranchTag.cs b/src/GitVersion.Configuration/Init/SetConfig/SetBranchTag.cs deleted file mode 100644 index 1bbc68517a..0000000000 --- a/src/GitVersion.Configuration/Init/SetConfig/SetBranchTag.cs +++ /dev/null @@ -1,52 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Extensions; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.SetConfig; - -internal class SetBranchTag(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - private string name; - private BranchConfigurationBuilder branchConfigurationBuilder; - - public SetBranchTag WithData(string configName, BranchConfigurationBuilder configurationBuilder) - { - this.branchConfigurationBuilder = configurationBuilder; - this.name = configName; - return this; - } - - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - if (result.IsNullOrWhiteSpace()) - { - return StepResult.InvalidResponseSelected(); - } - - var configureBranchStep = this.StepFactory.CreateStep(); - switch (result) - { - case "0": - steps.Enqueue(configureBranchStep.WithData(this.name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - case "1": - this.branchConfigurationBuilder.WithLabel(string.Empty); - steps.Enqueue(configureBranchStep.WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - default: - this.branchConfigurationBuilder.WithLabel(result); - steps.Enqueue(configureBranchStep.WithData(name, this.branchConfigurationBuilder)); - return StepResult.Ok(); - } - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"This sets the per-release tag which will be used for versions on this branch (beta, rc etc) - -0) Go Back -1) No tag - -Anything else will be used as the tag"; - - protected override string DefaultResult => "0"; -} diff --git a/src/GitVersion.Configuration/Init/SetNextVersion.cs b/src/GitVersion.Configuration/Init/SetNextVersion.cs deleted file mode 100644 index a146fde8cd..0000000000 --- a/src/GitVersion.Configuration/Init/SetNextVersion.cs +++ /dev/null @@ -1,31 +0,0 @@ -using GitVersion.Configuration.Init.Wizard; -using GitVersion.Extensions; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init; - -internal class SetNextVersion(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var editConfigStep = this.StepFactory.CreateStep(); - if (result.IsNullOrEmpty()) - { - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - } - - var configuration = configurationBuilder.Build(); - if (!SemanticVersion.TryParse(result, string.Empty, out var semVer, configuration.SemanticVersionFormat)) - return StepResult.InvalidResponseSelected(); - - configurationBuilder.WithNextVersion(semVer.ToString("t")); - steps.Enqueue(editConfigStep); - return StepResult.Ok(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => "What would you like to set the next version to (enter nothing to cancel)?"; - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/Init/StepResult.cs b/src/GitVersion.Configuration/Init/StepResult.cs deleted file mode 100644 index 10e0b9acdd..0000000000 --- a/src/GitVersion.Configuration/Init/StepResult.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace GitVersion.Configuration.Init; - -internal sealed class StepResult -{ - private StepResult() { } - - public static StepResult Ok() => new(); - - public static StepResult InvalidResponseSelected() => new() - { - InvalidResponse = true - }; - - public static StepResult SaveAndExit() => new() - { - Save = true, - Exit = true - }; - - public static StepResult ExitWithoutSaving() => new() - { - Save = false, - Exit = true - }; - - public bool Exit { get; private set; } - - public bool Save { get; private set; } - - public bool InvalidResponse { get; private set; } -} diff --git a/src/GitVersion.Configuration/Init/Wizard/ConfigInitStepFactory.cs b/src/GitVersion.Configuration/Init/Wizard/ConfigInitStepFactory.cs deleted file mode 100644 index 11d66fae97..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/ConfigInitStepFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -using GitVersion.Extensions; -using Microsoft.Extensions.DependencyInjection; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class ConfigInitStepFactory : IConfigInitStepFactory -{ - private readonly IServiceProvider sp; - - public ConfigInitStepFactory() - { - } - - public ConfigInitStepFactory(IServiceProvider sp) => this.sp = sp.NotNull(); - - public T CreateStep() where T : notnull => this.sp.GetRequiredService(); -} diff --git a/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizard.cs b/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizard.cs deleted file mode 100644 index 8f67f88601..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizard.cs +++ /dev/null @@ -1,29 +0,0 @@ -using GitVersion.Extensions; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class ConfigInitWizard(IConsole console, IConfigInitStepFactory stepFactory) : IConfigInitWizard -{ - private readonly IConsole console = console.NotNull(); - private readonly IConfigInitStepFactory stepFactory = stepFactory.NotNull(); - - public IGitVersionConfiguration? Run(IGitVersionConfiguration configuration, string workingDirectory) - { - this.console.WriteLine("GitVersion init will guide you through setting GitVersion up to work for you"); - var steps = new Queue(); - steps.Enqueue(this.stepFactory.CreateStep()); - - var configurationBuilder = ConfigurationBuilder.New.WithConfiguration(configuration); - while (steps.Count > 0) - { - var currentStep = steps.Dequeue(); - if (!currentStep.Apply(steps, configurationBuilder, workingDirectory)) - { - return null; - } - } - - return configurationBuilder.Build(); - } -} diff --git a/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizardStep.cs b/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizardStep.cs deleted file mode 100644 index 01de5138c3..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/ConfigInitWizardStep.cs +++ /dev/null @@ -1,61 +0,0 @@ -using GitVersion.Extensions; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal abstract class ConfigInitWizardStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) -{ - protected readonly IConsole Console = console.NotNull(); - protected readonly IFileSystem FileSystem = fileSystem.NotNull(); - protected readonly ILog Log = log.NotNull(); - protected readonly IConfigInitStepFactory StepFactory = stepFactory.NotNull(); - - public bool Apply(Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - this.Console.WriteLine(); - this.Console.WriteLine(GetPrompt(configurationBuilder, workingDirectory)); - this.Console.WriteLine(); - this.Console.Write("> "); - var input = this.Console.ReadLine(); - if (input == null) - { - this.Console.WriteLine("Would you like to save changes? (y/n)"); - input = this.Console.ReadLine(); - if (input == null || string.Equals(input, "n", StringComparison.OrdinalIgnoreCase)) return false; - if (string.Equals(input, "y", StringComparison.OrdinalIgnoreCase)) - { - steps.Clear(); - return true; - } - - InvalidResponse(steps); - return true; - } - var resultWithDefaultApplied = input.IsNullOrEmpty() ? DefaultResult : input; - var stepResult = HandleResult(resultWithDefaultApplied, steps, configurationBuilder, workingDirectory); - if (stepResult.InvalidResponse) - { - InvalidResponse(steps); - } - else if (stepResult.Exit) - { - steps.Clear(); - return stepResult.Save; - } - return true; - } - - private void InvalidResponse(Queue steps) - { - this.Console.WriteLine(); - using (this.Console.UseColor(ConsoleColor.Red)) - { - this.Console.WriteLine("Invalid response!"); - } - steps.Enqueue(this); - } - - protected abstract StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory); - protected abstract string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory); - protected abstract string? DefaultResult { get; } -} diff --git a/src/GitVersion.Configuration/Init/Wizard/FinishedSetupStep.cs b/src/GitVersion.Configuration/Init/Wizard/FinishedSetupStep.cs deleted file mode 100644 index 3d759d78d4..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/FinishedSetupStep.cs +++ /dev/null @@ -1,10 +0,0 @@ -using GitVersion.Helpers; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class FinishedSetupStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : EditConfigStep(console, fileSystem, log, stepFactory) -{ - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => $"Questions are all done, you can now edit GitVersion's configuration further{PathHelper.NewLine}" + base.GetPrompt(configurationBuilder, workingDirectory); -} diff --git a/src/GitVersion.Configuration/Init/Wizard/GitFlowSetupStep.cs b/src/GitVersion.Configuration/Init/Wizard/GitFlowSetupStep.cs deleted file mode 100644 index bc65165617..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/GitFlowSetupStep.cs +++ /dev/null @@ -1,12 +0,0 @@ -using GitVersion.Configuration.Init.SetConfig; -using GitVersion.Helpers; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class GitFlowSetupStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : GlobalModeSetting(console, fileSystem, log, stepFactory) -{ - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) - => $"By default GitVersion will only increment the version of the 'develop' branch every commit, all other branches will increment when tagged{PathHelper.NewLine}{PathHelper.NewLine}" + base.GetPrompt(configurationBuilder, workingDirectory); -} diff --git a/src/GitVersion.Configuration/Init/Wizard/GitHubFlowStep.cs b/src/GitVersion.Configuration/Init/Wizard/GitHubFlowStep.cs deleted file mode 100644 index 6132cba6c6..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/GitHubFlowStep.cs +++ /dev/null @@ -1,11 +0,0 @@ -using GitVersion.Configuration.Init.SetConfig; -using GitVersion.Helpers; -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class GitHubFlowStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : GlobalModeSetting(console, fileSystem, log, stepFactory) -{ - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => $"By default GitVersion will only increment the version when tagged{PathHelper.NewLine}{PathHelper.NewLine}" + base.GetPrompt(configurationBuilder, workingDirectory); -} diff --git a/src/GitVersion.Configuration/Init/Wizard/IConfigInitStepFactory.cs b/src/GitVersion.Configuration/Init/Wizard/IConfigInitStepFactory.cs deleted file mode 100644 index 78e3d38df6..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/IConfigInitStepFactory.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace GitVersion.Configuration.Init.Wizard; - -internal interface IConfigInitStepFactory -{ - T CreateStep() where T : notnull; -} diff --git a/src/GitVersion.Configuration/Init/Wizard/IConfigInitWizard.cs b/src/GitVersion.Configuration/Init/Wizard/IConfigInitWizard.cs deleted file mode 100644 index 4e57edf56e..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/IConfigInitWizard.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace GitVersion.Configuration.Init.Wizard; - -internal interface IConfigInitWizard -{ - IGitVersionConfiguration? Run(IGitVersionConfiguration configuration, string workingDirectory); -} diff --git a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy1Step.cs b/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy1Step.cs deleted file mode 100644 index dcde1a151b..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy1Step.cs +++ /dev/null @@ -1,31 +0,0 @@ -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class PickBranchingStrategy1Step(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result?.ToLower()) - { - case "y": - this.Console.Write(@"Because you need to maintain multiple versions of your product in production at the same time, GitFlow is likely a good fit. - -GitFlow allows you to have new development happening on the 'develop' branch, patch issues in old minor versions with 'hotfix/' branches and support old major versions with 'support/' branches"); - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "n": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"GitVersion can try to recommend you a branching strategy based on a few questions. - -Do you need to maintain multiple versions of your application simultaneously in production? (y/n)"; - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy2Step.cs b/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy2Step.cs deleted file mode 100644 index a26d523fda..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy2Step.cs +++ /dev/null @@ -1,32 +0,0 @@ -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class PickBranchingStrategy2Step(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result?.ToLower()) - { - case "y": - this.Console.WriteLine("GitFlow is likely a good fit, the 'develop' branch can be used " + - "for active development while stabilising the next release."); - this.Console.WriteLine(); - this.Console.WriteLine("GitHubFlow is designed for a lightweight workflow where main is always " + - "good to deploy to production and feature branches are used to stabilise " + - "features, once stable they are merged to main and made available in the next release"); - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - case "n": - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - - return StepResult.InvalidResponseSelected(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => "Do you stabilise releases while continuing work on the next version? (y/n)"; - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy3Step.cs b/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy3Step.cs deleted file mode 100644 index 7efae6d418..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategy3Step.cs +++ /dev/null @@ -1,33 +0,0 @@ -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class PickBranchingStrategy3Step(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - switch (result?.ToLower()) - { - case "y": - this.Console.WriteLine("GitFlow could be a better fit than GitHubFlow for you."); - this.Console.WriteLine(); - this.Console.WriteLine("GitVersion increments the SemVer for each commit on the develop branch by default, " + - "this means all packages built from develop can be published to a single NuGet feed."); - break; - case "n": - this.Console.WriteLine("We recommend the GitHubFlow branching strategy, it sounds like you will " + - "not benefit from the additional complexity that GitFlow introduces"); - break; - default: - return StepResult.InvalidResponseSelected(); - } - - steps.Enqueue(this.StepFactory.CreateStep()); - return StepResult.Ok(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => "Do you need to build nightly or consume packages the CI build creates without releasing those versions? (y/n)"; - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategyStep.cs b/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategyStep.cs deleted file mode 100644 index 3aef6a2543..0000000000 --- a/src/GitVersion.Configuration/Init/Wizard/PickBranchingStrategyStep.cs +++ /dev/null @@ -1,36 +0,0 @@ -using GitVersion.Logging; - -namespace GitVersion.Configuration.Init.Wizard; - -internal class PickBranchingStrategyStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory) - : ConfigInitWizardStep(console, fileSystem, log, stepFactory) -{ - protected override StepResult HandleResult(string? result, Queue steps, ConfigurationBuilder configurationBuilder, string workingDirectory) - { - var returnToStep = this.StepFactory.CreateStep(); - switch (result) - { - case "1": - steps.Enqueue(this.StepFactory.CreateStep().WithData(returnToStep, true)); - break; - case "2": - steps.Enqueue(this.StepFactory.CreateStep().WithData(returnToStep, true)); - break; - case "3": - steps.Enqueue(this.StepFactory.CreateStep()); - break; - default: - return StepResult.InvalidResponseSelected(); - } - - return StepResult.Ok(); - } - - protected override string GetPrompt(ConfigurationBuilder configurationBuilder, string workingDirectory) => @"The way you will use GitVersion will change a lot based on your branching strategy. What branching strategy will you be using: - -1) GitFlow (or similar) -2) GitHubFlow -3) Unsure, tell me more"; - - protected override string? DefaultResult => null; -} diff --git a/src/GitVersion.Configuration/PublicAPI.Unshipped.txt b/src/GitVersion.Configuration/PublicAPI.Unshipped.txt index 0e8718d52c..22844134c1 100644 --- a/src/GitVersion.Configuration/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Configuration/PublicAPI.Unshipped.txt @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable GitVersion.Configuration.ConfigurationException GitVersion.Configuration.ConfigurationException.ConfigurationException() -> void GitVersion.Configuration.ConfigurationException.ConfigurationException(string! message, System.Exception! innerException) -> void @@ -7,6 +7,3 @@ GitVersion.Configuration.ConfigurationException.ConfigurationException(string! m GitVersion.Configuration.GitVersionConfigurationModule GitVersion.Configuration.GitVersionConfigurationModule.GitVersionConfigurationModule() -> void GitVersion.Configuration.GitVersionConfigurationModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void -GitVersion.Configuration.Init.GitVersionInitModule -GitVersion.Configuration.Init.GitVersionInitModule.GitVersionInitModule() -> void -GitVersion.Configuration.Init.GitVersionInitModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void \ No newline at end of file diff --git a/src/GitVersion.Core/Configuration/IConfigurationProvider.cs b/src/GitVersion.Core/Configuration/IConfigurationProvider.cs index 7d4030db4d..14a4731776 100644 --- a/src/GitVersion.Core/Configuration/IConfigurationProvider.cs +++ b/src/GitVersion.Core/Configuration/IConfigurationProvider.cs @@ -3,5 +3,4 @@ namespace GitVersion.Configuration; public interface IConfigurationProvider { IGitVersionConfiguration Provide(IReadOnlyDictionary? overrideConfiguration = null); - void Init(string workingDirectory); } diff --git a/src/GitVersion.Core/Extensions/StringExtensions.cs b/src/GitVersion.Core/Extensions/StringExtensions.cs index 121387dac4..dc10da112e 100644 --- a/src/GitVersion.Core/Extensions/StringExtensions.cs +++ b/src/GitVersion.Core/Extensions/StringExtensions.cs @@ -61,8 +61,6 @@ public static bool IsSwitch(this string? value, string switchName) return string.Equals(switchName, value, StringComparison.OrdinalIgnoreCase); } - public static bool IsInit(this string singleArgument) => singleArgument.Equals("init", StringComparison.OrdinalIgnoreCase); - public static bool IsHelp(this string singleArgument) => (singleArgument == "?") || singleArgument.IsSwitch("h") || singleArgument.IsSwitch("help") || singleArgument.IsSwitch("?"); public static bool ArgumentRequiresValue(this string argument, int argumentIndex) diff --git a/src/GitVersion.Core/Options/GitVersionOptions.cs b/src/GitVersion.Core/Options/GitVersionOptions.cs index 8f3d2119e1..d3338a195c 100644 --- a/src/GitVersion.Core/Options/GitVersionOptions.cs +++ b/src/GitVersion.Core/Options/GitVersionOptions.cs @@ -13,7 +13,6 @@ public class GitVersionOptions public WixInfo WixInfo { get; } = new(); public Settings Settings { get; } = new(); - public bool Init; public bool Diag; public bool IsVersion; public bool IsHelp; diff --git a/src/GitVersion.Core/PublicAPI.Unshipped.txt b/src/GitVersion.Core/PublicAPI.Unshipped.txt index a0a180be0b..4e4d031c1a 100644 --- a/src/GitVersion.Core/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Core/PublicAPI.Unshipped.txt @@ -171,7 +171,6 @@ GitVersion.Configuration.IConfigurationFileLocator.ReadOverrideConfiguration(str GitVersion.Configuration.IConfigurationFileLocator.TryGetConfigurationFile(string? workingDirectory, string? projectRootDirectory, out string? configFilePath) -> bool GitVersion.Configuration.IConfigurationFileLocator.Verify(string? workingDirectory, string? projectRootDirectory) -> void GitVersion.Configuration.IConfigurationProvider -GitVersion.Configuration.IConfigurationProvider.Init(string! workingDirectory) -> void GitVersion.Configuration.IConfigurationProvider.Provide(System.Collections.Generic.IReadOnlyDictionary? overrideConfiguration = null) -> GitVersion.Configuration.IGitVersionConfiguration! GitVersion.Configuration.IGitVersionConfiguration GitVersion.Configuration.IGitVersionConfiguration.AssemblyFileVersioningFormat.get -> string? @@ -263,7 +262,6 @@ GitVersion.GitVersionOptions.ConfigurationInfo.get -> GitVersion.ConfigurationIn GitVersion.GitVersionOptions.Diag -> bool GitVersion.GitVersionOptions.Format -> string? GitVersion.GitVersionOptions.GitVersionOptions() -> void -GitVersion.GitVersionOptions.Init -> bool GitVersion.GitVersionOptions.IsHelp -> bool GitVersion.GitVersionOptions.IsVersion -> bool GitVersion.GitVersionOptions.LogFilePath -> string? @@ -815,7 +813,6 @@ static GitVersion.Extensions.StringExtensions.IsEmpty(this string? value) -> boo static GitVersion.Extensions.StringExtensions.IsEquivalentTo(this string! self, string? other) -> bool static GitVersion.Extensions.StringExtensions.IsFalse(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsHelp(this string! singleArgument) -> bool -static GitVersion.Extensions.StringExtensions.IsInit(this string! singleArgument) -> bool static GitVersion.Extensions.StringExtensions.IsNullOrEmpty(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsNullOrWhiteSpace(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsSwitch(this string? value, string! switchName) -> bool