chore: small refactorings
This commit is contained in:
@@ -20,6 +20,15 @@ namespace Cli
|
||||
}
|
||||
|
||||
public async Task Run(string workingDir)
|
||||
{
|
||||
var repoBasePath = await GetRepoBasePath(workingDir);
|
||||
var chosenService = await ChooseService(repoBasePath);
|
||||
var selection = await SelectVersion(repoBasePath, chosenService);
|
||||
await AddVersionTagToRepo(repoBasePath, selection.Version.ToString());
|
||||
await PushToRemote(repoBasePath);
|
||||
}
|
||||
|
||||
private async Task<string> GetRepoBasePath(string workingDir)
|
||||
{
|
||||
var repoBasePath = "";
|
||||
try
|
||||
@@ -32,6 +41,11 @@ namespace Cli
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
return repoBasePath;
|
||||
}
|
||||
|
||||
private async Task<string> ChooseService(string repoBasePath)
|
||||
{
|
||||
var services = new List<string>();
|
||||
try
|
||||
{
|
||||
@@ -54,7 +68,11 @@ namespace Cli
|
||||
.AddChoices(services));
|
||||
}
|
||||
|
||||
return chosenService;
|
||||
}
|
||||
|
||||
private async Task<Selection> SelectVersion(string repoBasePath, string chosenService)
|
||||
{
|
||||
var versionInfo = await _mediator.Send(new GetVersionInformationFromRepo.Query(repoBasePath, chosenService));
|
||||
Selection selection;
|
||||
if (versionInfo != null)
|
||||
@@ -90,17 +108,11 @@ namespace Cli
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _mediator.Send(new AddTagToGitRepo.Command(workingDir, selection.Version.ToString()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.Markup("[red]Error:[/] Unable to write Tag to repository\n\n");
|
||||
AnsiConsole.WriteException(ex);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
private async Task PushToRemote(string workingDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _mediator.Send(new PushCommitsToRemote.Command(workingDir));
|
||||
@@ -112,5 +124,19 @@ namespace Cli
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddVersionTagToRepo(string workingDir, string tag)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _mediator.Send(new AddTagToGitRepo.Command(workingDir, tag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.Markup("[red]Error:[/] Unable to write Tag to repository\n\n");
|
||||
AnsiConsole.WriteException(ex);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user