mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-23 01:36:57 -08:00
Make command for retreiving line count work
This commit is contained in:
parent
88452bd74d
commit
156bb31831
2 changed files with 50 additions and 0 deletions
43
src/Commands/QueryCommitChangedLines.cs
Normal file
43
src/Commands/QueryCommitChangedLines.cs
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue