mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: get count of changed file (without untracked) directly (#316)
This commit is contained in:
parent
8c16ded6bd
commit
3bcf4e128e
5 changed files with 34 additions and 8 deletions
26
src/Commands/CountLocalChangesWithoutUntracked.cs
Normal file
26
src/Commands/CountLocalChangesWithoutUntracked.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SourceGit.Commands
|
||||||
|
{
|
||||||
|
public class CountLocalChangesWithoutUntracked : Command
|
||||||
|
{
|
||||||
|
public CountLocalChangesWithoutUntracked(string repo)
|
||||||
|
{
|
||||||
|
WorkingDirectory = repo;
|
||||||
|
Context = repo;
|
||||||
|
Args = "status -uno --ignore-submodules=dirty --porcelain";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Result()
|
||||||
|
{
|
||||||
|
var rs = ReadToEnd();
|
||||||
|
if (rs.IsSuccess)
|
||||||
|
{
|
||||||
|
var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
return lines.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,9 +30,9 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result();
|
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (changes.Count > 0)
|
if (changes > 0)
|
||||||
{
|
{
|
||||||
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,9 +30,9 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result();
|
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (changes.Count > 0)
|
if (changes > 0)
|
||||||
{
|
{
|
||||||
if (AutoStash)
|
if (AutoStash)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,9 +86,9 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
if (CheckoutAfterCreated)
|
if (CheckoutAfterCreated)
|
||||||
{
|
{
|
||||||
var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result();
|
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (changes.Count > 0)
|
if (changes > 0)
|
||||||
{
|
{
|
||||||
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,9 +129,9 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result();
|
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||||
var needPopStash = false;
|
var needPopStash = false;
|
||||||
if (changes.Count > 0)
|
if (changes > 0)
|
||||||
{
|
{
|
||||||
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
if (PreAction == Models.DealWithLocalChanges.StashAndReaply)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue