Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbf09be431 |
@@ -26,7 +26,8 @@ namespace Cli
|
||||
var chosenService = await ChooseService(repoBasePath);
|
||||
var selection = await SelectVersion(repoBasePath, chosenService);
|
||||
await AddVersionTagToRepo(repoBasePath, selection.Version.ToString());
|
||||
await PushToRemote(repoBasePath);
|
||||
await PushTagsToRemote(repoBasePath);
|
||||
await PushCommitsToRemote(repoBasePath);
|
||||
}
|
||||
|
||||
private async Task<string> GetRepoBasePath(string workingDir)
|
||||
@@ -112,11 +113,27 @@ namespace Cli
|
||||
return selection;
|
||||
}
|
||||
|
||||
private async Task PushToRemote(string workingDir)
|
||||
private async Task PushTagsToRemote(string workingDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _mediator.Send(new PushCommitsToRemote.Command(workingDir));
|
||||
var output = await _mediator.Send(new PushTagsToRemote.Command(workingDir));
|
||||
AnsiConsole.Write(output);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AnsiConsole.Markup("[red]Error:[/] Tag was written but unable to push to remote\n\n");
|
||||
AnsiConsole.WriteException(ex);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PushCommitsToRemote(string workingDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
var output = await _mediator.Send(new PushCommitsToRemote.Command(workingDir));
|
||||
AnsiConsole.Write(output);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<PackageId>Novaloop.UpdateTag</PackageId>
|
||||
<title>Updates the tag of a repo to the next chosen version according the semver symantic.</title>
|
||||
<PackageTags>semver;update-tag;tag;git</PackageTags>
|
||||
<Version>0.1.5</Version>
|
||||
<Version>0.1.7</Version>
|
||||
<Authors>Matthias Langhard</Authors>
|
||||
<Company>Novaloop AG</Company>
|
||||
<PackageProjectUrl>https://gitlab.com/novaloop-oss/novaloop.update-tag</PackageProjectUrl>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Application.Interfaces
|
||||
@@ -5,7 +6,7 @@ namespace Application.Interfaces
|
||||
public interface IGitRepoWriteService
|
||||
{
|
||||
void AddTag(string repoPath, string tag);
|
||||
Task<string> PushTags(string repoPath);
|
||||
Task<string> Push(string repoPath);
|
||||
Task<string> PushTags(string repoPath, CancellationToken cancellationToken);
|
||||
Task<string> Push(string repoPath, CancellationToken ct);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using System.Threading.Tasks;
|
||||
using Application.Interfaces;
|
||||
using MediatR;
|
||||
|
||||
namespace Application.Commands
|
||||
namespace Application.Queries
|
||||
{
|
||||
public class PushCommitsToRemote : AsyncRequestHandler<PushCommitsToRemote.Command>
|
||||
public class PushCommitsToRemote : IRequestHandler<PushCommitsToRemote.Command, string>
|
||||
{
|
||||
private readonly IGitRepoWriteService _gitRepoWriteService;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Application.Commands
|
||||
_gitRepoWriteService = gitRepoWriteService;
|
||||
}
|
||||
|
||||
public class Command : IRequest
|
||||
public class Command : IRequest<string>
|
||||
{
|
||||
public string RepoPath { get; }
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace Application.Commands
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task Handle(Command request, CancellationToken cancellationToken)
|
||||
|
||||
public async Task<string> Handle(Command request, CancellationToken ct)
|
||||
{
|
||||
await _gitRepoWriteService.PushTags(request.RepoPath);
|
||||
await _gitRepoWriteService.Push(request.RepoPath);
|
||||
return await _gitRepoWriteService.Push(request.RepoPath, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/Core/Queries/PushTagsToRemote.cs
Normal file
33
src/Core/Queries/PushTagsToRemote.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Application.Interfaces;
|
||||
using MediatR;
|
||||
|
||||
namespace Application.Queries
|
||||
{
|
||||
public class PushTagsToRemote : IRequestHandler<PushTagsToRemote.Command, string>
|
||||
{
|
||||
private readonly IGitRepoWriteService _gitRepoWriteService;
|
||||
|
||||
public PushTagsToRemote(IGitRepoWriteService gitRepoWriteService)
|
||||
{
|
||||
_gitRepoWriteService = gitRepoWriteService;
|
||||
}
|
||||
|
||||
public class Command : IRequest<string>
|
||||
{
|
||||
public string RepoPath { get; }
|
||||
|
||||
public Command(string repoPath)
|
||||
{
|
||||
RepoPath = repoPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> Handle(Command request, CancellationToken ct)
|
||||
{
|
||||
return await _gitRepoWriteService.PushTags(request.RepoPath, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Application.Interfaces;
|
||||
using CliWrap;
|
||||
@@ -14,21 +15,21 @@ namespace Infrastructure.Services
|
||||
repo.ApplyTag(tag);
|
||||
}
|
||||
|
||||
public async Task<string> PushTags(string repoPath)
|
||||
public async Task<string> PushTags(string repoPath, CancellationToken ct)
|
||||
{
|
||||
var result = await Cli.Wrap("git")
|
||||
.WithArguments("push --tags")
|
||||
.WithWorkingDirectory(repoPath)
|
||||
.ExecuteBufferedAsync();
|
||||
.ExecuteBufferedAsync(ct);
|
||||
return result.StandardOutput.Trim();
|
||||
}
|
||||
|
||||
public async Task<string> Push(string repoPath)
|
||||
public async Task<string> Push(string repoPath, CancellationToken ct)
|
||||
{
|
||||
var result = await Cli.Wrap("git")
|
||||
.WithArguments("push")
|
||||
.WithWorkingDirectory(repoPath)
|
||||
.ExecuteBufferedAsync();
|
||||
.ExecuteBufferedAsync(ct);
|
||||
|
||||
return result.StandardOutput.Trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user