Skip to content

Commit 07054ed

Browse files
committed
ConfigInitSteps, made constructor with the same parameters
1 parent fa2f7a4 commit 07054ed

File tree

11 files changed

+65
-42
lines changed

11 files changed

+65
-42
lines changed

src/GitVersionCore/Configuration/Init/BuildServer/AppVeyorSetup.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ internal enum ProjectVisibility
1515

1616
internal class AppVeyorSetup : ConfigInitWizardStep
1717
{
18-
private readonly ProjectVisibility _projectVisibility;
18+
private ProjectVisibility _projectVisibility;
1919

20-
public AppVeyorSetup(IConsole console, IFileSystem fileSystem, ILog log, ProjectVisibility visibility) : base(console, fileSystem, log)
20+
public AppVeyorSetup(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
21+
{
22+
}
23+
24+
public AppVeyorSetup WithData(ProjectVisibility visibility)
2125
{
2226
_projectVisibility = visibility;
27+
return this;
2328
}
2429

2530
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)

src/GitVersionCore/Configuration/Init/BuildServer/AppveyorPublicPrivate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
1818
steps.Enqueue(new EditConfigStep(Console, FileSystem, Log));
1919
return StepResult.Ok();
2020
case "1":
21-
steps.Enqueue(new AppVeyorSetup(Console, FileSystem, Log, ProjectVisibility.Public));
21+
steps.Enqueue(new AppVeyorSetup(Console, FileSystem, Log).WithData(ProjectVisibility.Public));
2222
return StepResult.Ok();
2323
case "2":
24-
steps.Enqueue(new AppVeyorSetup(Console, FileSystem, Log, ProjectVisibility.Private));
24+
steps.Enqueue(new AppVeyorSetup(Console, FileSystem, Log).WithData(ProjectVisibility.Private));
2525
return StepResult.Ok();
2626
}
2727
return StepResult.Ok();

src/GitVersionCore/Configuration/Init/EditConfigStep.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
3333
steps.Enqueue(new ConfigureBranches(Console, FileSystem, Log));
3434
return StepResult.Ok();
3535
case "5":
36-
steps.Enqueue(new GlobalModeSetting(new EditConfigStep(Console, FileSystem, Log), false, Console, FileSystem, Log));
36+
var editConfigStep = new EditConfigStep(Console, FileSystem, Log);
37+
steps.Enqueue(new GlobalModeSetting(Console, FileSystem, Log).WithData(editConfigStep, false));
3738
return StepResult.Ok();
3839
case "6":
3940
steps.Enqueue(new AssemblyVersioningSchemeSetting(Console, FileSystem, Log));

src/GitVersionCore/Configuration/Init/SetConfig/ConfigureBranch.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ namespace GitVersion.Configuration.Init.SetConfig
66
{
77
public class ConfigureBranch : ConfigInitWizardStep
88
{
9-
private readonly string name;
10-
private readonly BranchConfig branchConfig;
9+
private string name;
10+
private BranchConfig branchConfig;
1111

12-
public ConfigureBranch(string name, BranchConfig branchConfig, IConsole console, IFileSystem fileSystem, ILog log)
13-
: base(console, fileSystem, log)
12+
public ConfigureBranch(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
1413
{
15-
this.branchConfig = branchConfig;
16-
this.name = name;
14+
}
15+
16+
public ConfigureBranch WithData(string _name, BranchConfig _branchConfig)
17+
{
18+
branchConfig = _branchConfig;
19+
name = _name;
20+
return this;
1721
}
1822

1923
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)
@@ -24,10 +28,10 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
2428
steps.Enqueue(new ConfigureBranches(Console, FileSystem, Log));
2529
return StepResult.Ok();
2630
case "1":
27-
steps.Enqueue(new SetBranchTag(name, branchConfig, Console, FileSystem, Log));
31+
steps.Enqueue(new SetBranchTag(Console, FileSystem, Log).WithData(name, branchConfig));
2832
return StepResult.Ok();
2933
case "2":
30-
steps.Enqueue(new SetBranchIncrementMode(name, branchConfig, Console, FileSystem, Log));
34+
steps.Enqueue(new SetBranchIncrementMode(Console, FileSystem, Log).WithData(name, branchConfig));
3135
return StepResult.Ok();
3236
}
3337

src/GitVersionCore/Configuration/Init/SetConfig/ConfigureBranches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
3131
branchConfig = new BranchConfig {Name = foundBranch.Key};
3232
config.Branches.Add(foundBranch.Key, branchConfig);
3333
}
34-
steps.Enqueue(new ConfigureBranch(foundBranch.Key, branchConfig, Console, FileSystem, Log));
34+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(foundBranch.Key, branchConfig));
3535
return StepResult.Ok();
3636
}
3737
catch (ArgumentOutOfRangeException)

src/GitVersionCore/Configuration/Init/SetConfig/GlobalModeSetting.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ namespace GitVersion.Configuration.Init.SetConfig
77
{
88
public class GlobalModeSetting : ConfigInitWizardStep
99
{
10-
private readonly ConfigInitWizardStep returnToStep;
11-
private readonly bool isPartOfWizard;
10+
private ConfigInitWizardStep returnToStep;
11+
private bool isPartOfWizard;
1212

13-
public GlobalModeSetting(ConfigInitWizardStep returnToStep, bool isPartOfWizard, IConsole console, IFileSystem fileSystem, ILog log)
14-
: base(console, fileSystem, log)
13+
public GlobalModeSetting(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
1514
{
16-
this.returnToStep = returnToStep;
17-
this.isPartOfWizard = isPartOfWizard;
15+
}
16+
17+
public GlobalModeSetting WithData(ConfigInitWizardStep _returnToStep, bool _isPartOfWizard)
18+
{
19+
returnToStep = _returnToStep;
20+
isPartOfWizard = _isPartOfWizard;
21+
return this;
1822
}
1923

2024
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)

src/GitVersionCore/Configuration/Init/SetConfig/SetBranchIncrementMode.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,34 @@ namespace GitVersion.Configuration.Init.SetConfig
77
{
88
public class SetBranchIncrementMode : ConfigInitWizardStep
99
{
10-
private readonly string name;
11-
private readonly BranchConfig branchConfig;
10+
private string name;
11+
private BranchConfig branchConfig;
1212

13-
public SetBranchIncrementMode(string name, BranchConfig branchConfig, IConsole console, IFileSystem fileSystem, ILog log)
14-
: base(console, fileSystem, log)
13+
public SetBranchIncrementMode(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
1514
{
16-
this.name = name;
17-
this.branchConfig = branchConfig;
15+
}
16+
17+
public SetBranchIncrementMode WithData(string _name, BranchConfig _branchConfig)
18+
{
19+
branchConfig = _branchConfig;
20+
name = _name;
21+
return this;
1822
}
1923

2024
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)
2125
{
2226
switch (result)
2327
{
2428
case "0":
25-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
29+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(name, branchConfig));
2630
return StepResult.Ok();
2731
case "1":
2832
branchConfig.VersioningMode = VersioningMode.ContinuousDelivery;
29-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
33+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(name, branchConfig));
3034
return StepResult.Ok();
3135
case "2":
3236
branchConfig.VersioningMode = VersioningMode.ContinuousDeployment;
33-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
37+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(name, branchConfig));
3438
return StepResult.Ok();
3539
}
3640

src/GitVersionCore/Configuration/Init/SetConfig/SetBranchTag.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ namespace GitVersion.Configuration.Init.SetConfig
66
{
77
public class SetBranchTag : ConfigInitWizardStep
88
{
9-
private readonly string name;
10-
private readonly BranchConfig branchConfig;
9+
private string name;
10+
private BranchConfig branchConfig;
1111

12-
public SetBranchTag(string name, BranchConfig branchConfig, IConsole console, IFileSystem fileSystem, ILog log)
13-
: base(console, fileSystem, log)
12+
public SetBranchTag(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
1413
{
15-
this.name = name;
16-
this.branchConfig = branchConfig;
14+
}
15+
16+
public SetBranchTag WithData(string _name, BranchConfig _branchConfig)
17+
{
18+
branchConfig = _branchConfig;
19+
name = _name;
20+
return this;
1721
}
1822

1923
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)
@@ -26,15 +30,15 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
2630
switch (result)
2731
{
2832
case "0":
29-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
33+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData( name, branchConfig));
3034
return StepResult.Ok();
3135
case "1":
3236
branchConfig.Tag = string.Empty;
33-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
37+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(name, branchConfig));
3438
return StepResult.Ok();
3539
default:
3640
branchConfig.Tag = result;
37-
steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem, Log));
41+
steps.Enqueue(new ConfigureBranch(Console, FileSystem, Log).WithData(name, branchConfig));
3842
return StepResult.Ok();
3943
}
4044
}

src/GitVersionCore/Configuration/Init/Wizard/GitFlowSetupStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace GitVersion.Configuration.Init.Wizard
55
{
66
public class GitFlowSetupStep : GlobalModeSetting
77
{
8-
public GitFlowSetupStep(IConsole console, IFileSystem fileSystem, ILog log) : base(new FinishedSetupStep(console, fileSystem, log), true, console, fileSystem, log)
8+
public GitFlowSetupStep(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
99
{
1010
}
1111

src/GitVersionCore/Configuration/Init/Wizard/GitHubFlowStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace GitVersion.Configuration.Init.Wizard
55
{
66
public class GitHubFlowStep : GlobalModeSetting
77
{
8-
public GitHubFlowStep(IConsole console, IFileSystem fileSystem, ILog log) : base(new FinishedSetupStep(console, fileSystem, log), true, console, fileSystem, log)
8+
public GitHubFlowStep(IConsole console, IFileSystem fileSystem, ILog log) : base(console, fileSystem, log)
99
{
1010
}
1111

0 commit comments

Comments
 (0)