using GitManager.Domain.Models;
using GitManager.GitCLI.Commands.Parsing;
namespace GitManager.GitCLI.Commands
{
public record GitPullBranchCommandInput : IGitCommandInput
{
public string LocalPath { get; }
/// <summary>
/// When not specified, the current local checked out branch will be pulled.
/// </summary>
public string? Branch { get; }
public GitPullBranchCommandInput(string localPath, string? branch = null)
{
LocalPath = localPath;
Branch = branch;
}
}
public class GitPullBranchCommand : IGitCommand<string, GitPullBranchCommandInput>
{
private readonly IGitCommandStrategy _gitCommandStrategy;
public GitPullBranchCommand(IGitCommandStrategy gitCommandStrategy)
{
_gitCommandStrategy = gitCommandStrategy;
}
public async Task<string> ExecuteAsync(GitPullBranchCommandInput input)
{
//var command = "branch --list --all";
var command = "pull";
var result = await _gitCommandStrategy.ExecuteAsync(command, input.LocalPath);
return result;
}
}
}