/
vasiukoff
/
sg
Обзор
Документация
Войти
/
vasiukoff
/
sg
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Commands/Statistics.cs
37 строк
1 KB
Nathan Baulch
refactor: streamline certain string operations (#1540)
07 июл 2025, 12:36
Не верифицирован
07 июл 2025, 12:36
5c9d96f
Код
Авторство
О чём код?
using System.IO; using System.Threading.Tasks; namespace SourceGit.Commands { public class Statistics : Command { public Statistics(string repo, int max) { WorkingDirectory = repo; Context = repo; Args = $"log --date-order --branches --remotes -{max} --format=%ct$%aN±%aE"; } public async Task<Models.Statistics> ReadAsync() { var statistics = new Models.Statistics(); var rs = await ReadToEndAsync().ConfigureAwait(false); if (!rs.IsSuccess) return statistics; var sr = new StringReader(rs.StdOut); while (sr.ReadLine() is { } line) ParseLine(statistics, line); statistics.Complete(); return statistics; } private void ParseLine(Models.Statistics statistics, string line) { var parts = line.Split('$', 2); if (parts.Length == 2 && double.TryParse(parts[0], out var date)) statistics.AddCommit(parts[1], date); } } }