Skip to content

Commit

Permalink
Fix null variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrariofilippo committed May 11, 2023
1 parent 39f0dfc commit 7d0db5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Files.App/Helpers/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
13 changes: 8 additions & 5 deletions src/Files.App/ViewModels/DirectoryPropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}

0 comments on commit 7d0db5b

Please sign in to comment.