mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 19:02:39 +08:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class MergeTool : Command
|
|
{
|
|
public MergeTool(string repo, string file)
|
|
{
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
_file = string.IsNullOrEmpty(file) ? string.Empty : file.Quoted();
|
|
}
|
|
|
|
public async Task<bool> OpenAsync()
|
|
{
|
|
var tool = Native.OS.GetDiffMergeTool(false);
|
|
if (tool == null)
|
|
{
|
|
App.RaiseException(Context, "Invalid merge tool in preference setting!");
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(tool.Cmd))
|
|
{
|
|
Args = $"mergetool {_file}";
|
|
}
|
|
else
|
|
{
|
|
var cmd = $"{tool.Exec.Quoted()} {tool.Cmd}";
|
|
Args = $"-c mergetool.sourcegit.cmd={cmd.Quoted()} -c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true mergetool --tool=sourcegit {_file}";
|
|
}
|
|
|
|
return await ExecAsync().ConfigureAwait(false);
|
|
}
|
|
|
|
private string _file;
|
|
}
|
|
}
|