enhance: histories filter

* set upstream branch using the same filter mode when change the filter mode of local branch
* also excludes the decorators when current filter mode is excluding.

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-20 11:27:43 +08:00
parent 4796024483
commit 86d7541a7c
No known key found for this signature in database
2 changed files with 8 additions and 22 deletions

View file

@ -320,6 +320,8 @@ namespace SourceGit.Models
{
builder.Append("--exclude=");
builder.Append(b);
builder.Append(" --decorate-refs-exclude=refs/heads/");
builder.Append(b);
builder.Append(' ');
}
}
@ -332,6 +334,8 @@ namespace SourceGit.Models
{
builder.Append("--exclude=");
builder.Append(r);
builder.Append(" --decorate-refs-exclude=refs/remotes/");
builder.Append(r);
builder.Append(' ');
}
}
@ -344,6 +348,8 @@ namespace SourceGit.Models
{
builder.Append("--exclude=");
builder.Append(t);
builder.Append(" --decorate-refs-exclude=refs/tags/");
builder.Append(t);
builder.Append(' ');
}
}

View file

@ -724,28 +724,8 @@ namespace SourceGit.ViewModels
if (!changed)
return;
if (isLocal && !string.IsNullOrEmpty(branch.Upstream) && mode != Models.FilterMode.Excluded)
{
var upstream = branch.Upstream;
var canUpdateUpstream = true;
foreach (var filter in _settings.HistoriesFilters)
{
bool matched = false;
if (filter.Type == Models.FilterType.RemoteBranch)
matched = filter.Pattern.Equals(upstream, StringComparison.Ordinal);
else if (filter.Type == Models.FilterType.RemoteBranchFolder)
matched = upstream.StartsWith(filter.Pattern, StringComparison.Ordinal);
if (matched && filter.Mode == Models.FilterMode.Excluded)
{
canUpdateUpstream = false;
break;
}
}
if (canUpdateUpstream)
_settings.UpdateHistoriesFilter(upstream, Models.FilterType.RemoteBranch, mode);
}
if (isLocal && !string.IsNullOrEmpty(branch.Upstream))
_settings.UpdateHistoriesFilter(branch.Upstream, Models.FilterType.RemoteBranch, mode);
}
else
{