From 7d0db5b00391f5467e17bc301679420eb72650fd Mon Sep 17 00:00:00 2001 From: Filippo Ferrario Date: Thu, 11 May 2023 19:05:26 +0200 Subject: [PATCH] Fix null variable --- src/Files.App/Helpers/GitHelpers.cs | 1 + .../ViewModels/DirectoryPropertiesViewModel.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Files.App/Helpers/GitHelpers.cs b/src/Files.App/Helpers/GitHelpers.cs index f5e5d5856f90..0a5e0268380c 100644 --- a/src/Files.App/Helpers/GitHelpers.cs +++ b/src/Files.App/Helpers/GitHelpers.cs @@ -43,6 +43,7 @@ public static string[] GetLocalBranchesNames(string? path) return repository.Branches .Where(b => !b.IsRemote) .OrderByDescending(b => b.IsCurrentRepositoryHead) + .ThenByDescending(b => b.Tip.Committer.When) .Select(b => b.FriendlyName) .ToArray(); } diff --git a/src/Files.App/ViewModels/DirectoryPropertiesViewModel.cs b/src/Files.App/ViewModels/DirectoryPropertiesViewModel.cs index 636e25c1f393..e7eec3ed1ec8 100644 --- a/src/Files.App/ViewModels/DirectoryPropertiesViewModel.cs +++ b/src/Files.App/ViewModels/DirectoryPropertiesViewModel.cs @@ -42,12 +42,15 @@ public void UpdateGitInfo(bool isGitRepository, string activeBranch, string[] br ? string.Format("Branch".GetLocalizedResource(), activeBranch) : null; - BranchesNames.Clear(); - foreach (var name in branches) - BranchesNames.Add(name); + if (isGitRepository) + { + BranchesNames.Clear(); + foreach (var name in branches) + BranchesNames.Add(name); - ActiveBranchIndex = BranchesNames.IndexOf(activeBranch); - SelectedBranchIndex = ActiveBranchIndex; + ActiveBranchIndex = BranchesNames.IndexOf(activeBranch); + SelectedBranchIndex = ActiveBranchIndex; + } } } }