feature<Histories>: add reword/squash context menu for HEAD commit

This commit is contained in:
leo 2021-08-05 20:38:38 +08:00
parent 76f192785c
commit 59fa5304d8
9 changed files with 279 additions and 6 deletions

View file

@ -5,14 +5,12 @@ namespace SourceGit.Commands {
/// `git commit`命令
/// </summary>
public class Commit : Command {
private string msg = null;
public Commit(string repo, string message, bool amend) {
msg = Path.GetTempFileName();
File.WriteAllText(msg, message);
var file = Path.GetTempFileName();
File.WriteAllText(file, message);
Cwd = repo;
Args = $"commit --file=\"{msg}\"";
Args = $"commit --file=\"{file}\"";
if (amend) Args += " --amend --no-edit";
}
}

16
src/Commands/Reword.cs Normal file
View file

@ -0,0 +1,16 @@
using System.IO;
namespace SourceGit.Commands {
/// <summary>
/// 编辑HEAD的提交信息
/// </summary>
public class Reword : Command {
public Reword(string repo, string msg) {
var tmp = Path.GetTempFileName();
File.WriteAllText(tmp, msg);
Cwd = repo;
Args = $"commit --amend --allow-empty --file=\"{tmp}\"";
}
}
}