mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-25 03:12:21 +08:00
29 lines
801 B
C#
29 lines
801 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class CountLocalChanges : Command
|
|
{
|
|
public CountLocalChanges(string repo, bool includeUntracked)
|
|
{
|
|
var option = includeUntracked ? "-uall" : "-uno";
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
Args = $"--no-optional-locks status {option} --ignore-submodules=all --porcelain";
|
|
}
|
|
|
|
public async Task<int> GetResultAsync()
|
|
{
|
|
var rs = await ReadToEndAsync().ConfigureAwait(false);
|
|
if (rs.IsSuccess)
|
|
{
|
|
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
|
|
return lines.Length;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|