feature: support --signoff for git commit command (#591)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-23 09:45:52 +08:00
parent b9d7f908c9
commit 06fd49ba92
No known key found for this signature in database
10 changed files with 48 additions and 9 deletions

View file

@ -4,17 +4,37 @@ namespace SourceGit.Commands
{
public class Commit : Command
{
public Commit(string repo, string message, bool amend)
public Commit(string repo, string message, bool amend, bool signOff)
{
var file = Path.GetTempFileName();
File.WriteAllText(file, message);
_tmpFile = Path.GetTempFileName();
File.WriteAllText(_tmpFile, message);
WorkingDirectory = repo;
Context = repo;
TraitErrorAsOutput = true;
Args = $"commit --allow-empty --file=\"{file}\"";
Args = $"commit --allow-empty --file=\"{_tmpFile}\"";
if (amend)
Args += " --amend --no-edit";
if (signOff)
Args += " --signoff";
}
public bool Run()
{
var succ = Exec();
try
{
File.Delete(_tmpFile);
}
catch
{
// Ignore
}
return succ;
}
private string _tmpFile = string.Empty;
}
}