From 8c16ded6bd4038749414448678b37a582fe07f32 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 7 Aug 2024 15:38:18 +0800 Subject: [PATCH] enhance: ignore untracked files when calculate local changes in checkout/create branch/pull (#316) --- src/ViewModels/Checkout.cs | 4 ++-- src/ViewModels/CheckoutCommit.cs | 8 ++------ src/ViewModels/CreateBranch.cs | 5 +++-- src/ViewModels/Pull.cs | 3 ++- src/Views/CheckoutCommit.axaml | 5 ++--- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 84f039d0..056536b5 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -28,11 +28,11 @@ namespace SourceGit.ViewModels _repo.SetWatcherEnabled(false); ProgressDescription = $"Checkout '{Branch}' ..."; - var hasLocalChanges = _repo.WorkingCopyChangesCount > 0; return Task.Run(() => { + var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); var needPopStash = false; - if (hasLocalChanges) + if (changes.Count > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs index 841659c4..7c864f2c 100644 --- a/src/ViewModels/CheckoutCommit.cs +++ b/src/ViewModels/CheckoutCommit.cs @@ -10,11 +10,6 @@ namespace SourceGit.ViewModels private set; } - public bool HasLocalChanges - { - get => _repo.WorkingCopyChangesCount > 0; - } - public bool AutoStash { get => _autoStash; @@ -35,8 +30,9 @@ namespace SourceGit.ViewModels return Task.Run(() => { + var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); var needPopStash = false; - if (HasLocalChanges) + if (changes.Count > 0) { if (AutoStash) { diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 2afcef4a..d8706952 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -86,8 +86,9 @@ namespace SourceGit.ViewModels { if (CheckoutAfterCreated) { - bool needPopStash = false; - if (_repo.WorkingCopyChangesCount > 0) + var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); + var needPopStash = false; + if (changes.Count > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 676800aa..acb13483 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -129,8 +129,9 @@ namespace SourceGit.ViewModels return Task.Run(() => { + var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); var needPopStash = false; - if (_repo.WorkingCopyChangesCount > 0) + if (changes.Count > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { diff --git a/src/Views/CheckoutCommit.axaml b/src/Views/CheckoutCommit.axaml index 7c131c38..521d2b08 100644 --- a/src/Views/CheckoutCommit.axaml +++ b/src/Views/CheckoutCommit.axaml @@ -26,9 +26,8 @@ - + Text="{DynamicResource Text.Checkout.LocalChanges}"/> +