Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Revamp init wizard for v6 #3899

Merged
merged 2 commits into from
Feb 6, 2024
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
1 change: 1 addition & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* TrackReleaseBranches
* VersionInBranchName
* TrunkBased
* The initialization wizard has been removed.

## v5.0.0

Expand Down
1 change: 0 additions & 1 deletion src/GitVersion.App.Tests/HelpWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void AllArgsAreInHelp()
var lookup = new Dictionary<string, string>
{
{ nameof(Arguments.TargetUrl), "/url" },
{ nameof(Arguments.Init), "init" },
{ nameof(Arguments.TargetBranch), "/b" },
{ nameof(Arguments.LogFilePath) , "/l" },
{ nameof(Arguments.OutputFile) , "/outputfile" },
Expand Down
9 changes: 0 additions & 9 deletions src/GitVersion.App/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/GitVersion.App/Arguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +85,6 @@ public GitVersionOptions ToOptions()
UpdateWixVersionFile = UpdateWixVersionFile
},

Init = Init,
Diag = Diag,
IsVersion = IsVersion,
IsHelp = IsHelp,
Expand Down
9 changes: 1 addition & 8 deletions src/GitVersion.App/GitVersionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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());
}
Expand Down

This file was deleted.

This file was deleted.

23 changes: 1 addition & 22 deletions src/GitVersion.Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,15 +10,13 @@ internal class ConfigurationProvider(
IFileSystem fileSystem,
ILog log,
IConfigurationFileLocator configFileLocator,
IOptions<GitVersionOptions> options,
IConfigInitWizard configInitWizard)
IOptions<GitVersionOptions> options)
: IConfigurationProvider
{
private readonly IFileSystem fileSystem = fileSystem.NotNull();
private readonly ILog log = log.NotNull();
private readonly IConfigurationFileLocator configFileLocator = configFileLocator.NotNull();
private readonly IOptions<GitVersionOptions> options = options.NotNull();
private readonly IConfigInitWizard configInitWizard = configInitWizard.NotNull();

public IGitVersionConfiguration Provide(IReadOnlyDictionary<object, object?>? overrideConfiguration)
{
Expand All @@ -33,23 +29,6 @@ public IGitVersionConfiguration Provide(IReadOnlyDictionary<object, object?>? 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<object, object?>? overrideConfiguration = null)
{
Expand Down
4 changes: 0 additions & 4 deletions src/GitVersion.Configuration/GitVersionConfigurationModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using GitVersion.Configuration.Init;
using GitVersion.Extensions;
using GitVersion.VersionCalculation.Caching;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -9,8 +7,6 @@ public class GitVersionConfigurationModule : IGitVersionModule
{
public void RegisterTypes(IServiceCollection services)
{
services.AddModule(new GitVersionInitModule());

services.AddSingleton<IGitVersionCacheKeyFactory, GitVersionCacheKeyFactory>();
services.AddSingleton<IConfigurationProvider, ConfigurationProvider>();
services.AddSingleton<IConfigurationFileLocator, ConfigurationFileLocator>();
Expand Down
123 changes: 0 additions & 123 deletions src/GitVersion.Configuration/Init/BuildServer/AppVeyorSetup.cs

This file was deleted.

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions src/GitVersion.Configuration/Init/BuildServer/SetupBuildScripts.cs

This file was deleted.

Loading
Loading