mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature: support --signoff
for git commit
command (#591)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
b9d7f908c9
commit
06fd49ba92
10 changed files with 48 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue