Compare commits

...

2 commits

Author SHA1 Message Date
Gadfly
12d2b7721c
fix: Trim and normalize commit message history line endings (#1335)
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
2025-05-20 10:56:02 +08:00
leo
119b0fe95c
feature: log output of custom action if Wait for action exit enabled (#1334)
Signed-off-by: leo <longshuang@msn.cn>
2025-05-20 09:17:00 +08:00
3 changed files with 10 additions and 4 deletions

View file

@ -27,7 +27,7 @@ namespace SourceGit.Commands
}
}
public static void RunAndWait(string repo, string file, string args, Action<string> outputHandler)
public static void RunAndWait(string repo, string file, string args, Models.ICommandLog log)
{
var start = new ProcessStartInfo();
start.FileName = file;
@ -40,20 +40,22 @@ namespace SourceGit.Commands
start.StandardErrorEncoding = Encoding.UTF8;
start.WorkingDirectory = repo;
log?.AppendLine($"$ {file} {args}\n");
var proc = new Process() { StartInfo = start };
var builder = new StringBuilder();
proc.OutputDataReceived += (_, e) =>
{
if (e.Data != null)
outputHandler?.Invoke(e.Data);
log?.AppendLine(e.Data);
};
proc.ErrorDataReceived += (_, e) =>
{
if (e.Data != null)
{
outputHandler?.Invoke(e.Data);
log?.AppendLine(e.Data);
builder.AppendLine(e.Data);
}
};

View file

@ -417,6 +417,7 @@ namespace SourceGit.Models
public void PushCommitMessage(string message)
{
message = message.Trim().ReplaceLineEndings("\n");
var existIdx = CommitMessages.IndexOf(message);
if (existIdx == 0)
return;

View file

@ -36,13 +36,16 @@ namespace SourceGit.ViewModels
_repo.SetWatcherEnabled(false);
ProgressDescription = "Run custom action ...";
var log = _repo.CreateLog(CustomAction.Name);
return Task.Run(() =>
{
if (CustomAction.WaitForExit)
Commands.ExecuteCustomAction.RunAndWait(_repo.FullPath, CustomAction.Executable, _args, output => CallUIThread(() => ProgressDescription = output));
Commands.ExecuteCustomAction.RunAndWait(_repo.FullPath, CustomAction.Executable, _args, log);
else
Commands.ExecuteCustomAction.Run(_repo.FullPath, CustomAction.Executable, _args);
log.Complete();
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
});