2024-07-09 02:56:23 -07:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Commit : Command
|
|
|
|
|
{
|
2024-07-06 19:28:14 -07:00
|
|
|
|
public Commit(string repo, string message, bool autoStage, bool amend, bool allowEmpty = false)
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2021-08-05 05:38:38 -07:00
|
|
|
|
var file = Path.GetTempFileName();
|
|
|
|
|
File.WriteAllText(file, message);
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
WorkingDirectory = repo;
|
|
|
|
|
Context = repo;
|
2024-07-09 02:56:23 -07:00
|
|
|
|
TraitErrorAsOutput = true;
|
2021-08-05 05:38:38 -07:00
|
|
|
|
Args = $"commit --file=\"{file}\"";
|
2024-07-06 19:28:14 -07:00
|
|
|
|
if (autoStage)
|
|
|
|
|
Args += " --all";
|
2024-03-31 01:54:29 -07:00
|
|
|
|
if (amend)
|
|
|
|
|
Args += " --amend --no-edit";
|
|
|
|
|
if (allowEmpty)
|
|
|
|
|
Args += " --allow-empty";
|
2024-07-09 02:56:23 -07:00
|
|
|
|
|
|
|
|
|
UseSSHAskpass();
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|