Skip to content

Commit 4aaa526

Browse files
committed
feat: Add solo mode functionality to repository toolbar
- Add a new localization string for solo mode functionality on HEAD. - Add a solo mode button to the repository toolbar for toggling the current head view. - Add solo commit filter mode for the current HEAD branch. - Add "HEAD" & `HEAD_SHA` both is useful/comparable while `HEAD` is Changed
1 parent 02e450c commit 4aaa526

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/ViewModels/Repository.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using System.Text;
56
using System.Text.Json;
67
using System.Threading;
@@ -1062,10 +1063,13 @@ public void SetTagFilterMode(Models.Tag tag, Models.FilterMode mode)
10621063
if (changed)
10631064
RefreshHistoriesFilters(true);
10641065
}
1066+
10651067
public void SetSoloCommitFilterMode(Models.Commit commit, Models.FilterMode mode)
1066-
{
1067-
SetSoloCommitFilterMode(commit.SHA[..10], mode);
1068-
}
1068+
=> SetSoloCommitFilterMode(commit.SHA[..10], mode);
1069+
1070+
1071+
public void SetSoloCommitFilterMode(IEnumerable<Models.Commit> commits, Models.FilterMode mode)
1072+
=> SetSoloCommitFilterMode(commits.Select(x => x.SHA[..10]).ToList(), mode);
10691073

10701074
public void SetSoloCommitFilterMode(string sha, Models.FilterMode mode)
10711075
{
@@ -1074,6 +1078,16 @@ public void SetSoloCommitFilterMode(string sha, Models.FilterMode mode)
10741078
RefreshHistoriesFilters(true);
10751079
}
10761080

1081+
public void SetSoloCommitFilterMode(IEnumerable<string> shas, Models.FilterMode mode)
1082+
{
1083+
bool changed = false;
1084+
foreach (var sha in shas)
1085+
changed |= _settings.UpdateHistoriesFilter(sha, Models.FilterType.SoloCommits, mode);
1086+
1087+
if (changed)
1088+
RefreshHistoriesFilters(true);
1089+
}
1090+
10771091
public void SetBranchFilterMode(Models.Branch branch, Models.FilterMode mode, bool clearExists, bool refresh)
10781092
{
10791093
var node = FindBranchNode(branch.IsLocal ? _localBranchTrees : _remoteBranchTrees, branch.FullName);

src/Views/RepositoryToolbar.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private void SoloModeOnCurrentHead(object sender, RoutedEventArgs e)
467467
{
468468
if (DataContext is ViewModels.Repository { CurrentBranch: not null } repo)
469469
{
470-
repo.SetSoloCommitFilterMode(repo.CurrentBranch.Head[..10], Models.FilterMode.Included);
470+
repo.SetSoloCommitFilterMode(["HEAD", repo.CurrentBranch.Head[..10]], Models.FilterMode.Included);
471471
e.Handled = true;
472472
}
473473
}

0 commit comments

Comments
 (0)