fix<Repository>: fix filter not work when there's no files under .git/refs/xxx/

This commit is contained in:
leo 2023-08-21 20:04:25 +08:00
parent 38810c440e
commit 4d7b16dc75

View file

@ -100,10 +100,12 @@ namespace SourceGit.Models {
// 未填写参数就检测,去掉无效的过滤 // 未填写参数就检测,去掉无效的过滤
if (Filters.Count > 0) { if (Filters.Count > 0) {
var invalidFilters = new List<string>(); var invalidFilters = new List<string>();
var branches = new Commands.Branches(Path).Result();
var tags = new Commands.Tags(Path).Result(); var tags = new Commands.Tags(Path).Result();
foreach (var filter in Filters) { foreach (var filter in Filters) {
if (filter.StartsWith("refs/")) { if (filter.StartsWith("refs/")) {
if (!ExistsInGitDir(filter)) invalidFilters.Add(filter); if (branches.FindIndex(b => b.FullName == filter) < 0) invalidFilters.Add(filter);
} else { } else {
if (tags.FindIndex(t => t.Name == filter) < 0) invalidFilters.Add(filter); if (tags.FindIndex(t => t.Name == filter) < 0) invalidFilters.Add(filter);
} }