diff --git a/src/Commands/QueryCommitChangedLines.cs b/src/Commands/QueryCommitChangedLines.cs new file mode 100644 index 00000000..d5605104 --- /dev/null +++ b/src/Commands/QueryCommitChangedLines.cs @@ -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; + } +} diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index bf9f57c9..455c530d 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -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();