sourcegit/src/Commands/CountLocalChangesWithoutUntracked.cs
leo 808302ce84
code_review: PR #1106
- Use new syntex `[...]` instead of `new char[] {...}` to create char arrays
- Use `string.ReplaceLineEndings('\n').Split('\n')` instead of `string.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries)` because that the `Signer` part may be missing

Signed-off-by: leo <longshuang@msn.cn>
2025-03-17 20:35:31 +08:00

26 lines
662 B
C#

using System;
namespace SourceGit.Commands
{
public class CountLocalChangesWithoutUntracked : Command
{
public CountLocalChangesWithoutUntracked(string repo)
{
WorkingDirectory = repo;
Context = repo;
Args = "--no-optional-locks status -uno --ignore-submodules=dirty --porcelain";
}
public int Result()
{
var rs = ReadToEnd();
if (rs.IsSuccess)
{
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
return lines.Length;
}
return 0;
}
}
}