Make command for retreiving line count work

This commit is contained in:
Bernat Borràs Civil 2025-01-12 19:41:14 +01:00
parent 88452bd74d
commit 156bb31831
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,43 @@
using System.Text.RegularExpressions;
namespace SourceGit.Commands
{
public class QueryCommitChangedLines : Command
{
public QueryCommitChangedLines(string repo, string sha)
{
WorkingDirectory = repo;
Context = repo;
Args = $"show --numstat --oneline {sha}";
}
public (int, int) Result()
{
_addedLines = 0;
_removedLines = 0;
_firstLine = true;
Exec();
return (_addedLines, _removedLines);
}
protected override void OnReadline(string line)
{
if (_firstLine) {
_firstLine = false;
return;
}
var parts = Regex.Split(line, @"\s+");
if (parts.Length >= 2)
{
_addedLines += int.Parse(parts[0]);
_removedLines += int.Parse(parts[1]);
}
}
private int _addedLines;
private int _removedLines;
private bool _firstLine;
}
}

View file

@ -635,6 +635,13 @@ namespace SourceGit.ViewModels
Dispatcher.UIThread.Invoke(() => FullMessage = fullMessage);
});
Task.Run(() =>
{
var lines = new Commands.QueryCommitChangedLines(_repo.FullPath, _commit.SHA).Result();
Console.WriteLine(lines);
//Dispatcher.UIThread.Invoke(() => FullMessage = fullMessage);
});
Task.Run(() =>
{
var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA, !_repo.HasAllowedSignersFile).Result();