Count failed loads as danger in hidden issues

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 20:14:47 +02:00
co-authored by Claude Sonnet 5.5
parent af6d03a5b1
commit e5fdc875af
3 changed files with 17 additions and 1 deletions
+6 -1
View File
@@ -61,9 +61,14 @@ func (s *Status) Issues() []Issue {
}
// HiddenIssues counts the issues of all loaded descendants and returns the
// most severe level among them.
// most severe level among them. A descendant whose load failed counts as one
// danger, since its state is unknown.
func (m *Submodule) HiddenIssues() (count int, worst Level) {
Walk(m.Children, func(c *Submodule) {
if c.Status == nil && c.Err != nil {
count++
worst = max(worst, LevelDanger)
}
for _, is := range c.Status.Issues() {
count++
worst = max(worst, is.Level)
+10
View File
@@ -1,6 +1,7 @@
package submodule
import (
"errors"
"slices"
"testing"
)
@@ -69,3 +70,12 @@ func TestUntrackedRepositoryWording(t *testing.T) {
}
}
}
func TestHiddenIssuesCountLoadErrors(t *testing.T) {
bad := &Submodule{Err: errors.New("boom")}
loading := &Submodule{}
parent := &Submodule{Children: []*Submodule{bad, loading}}
if n, w := parent.HiddenIssues(); n != 1 || w != LevelDanger {
t.Errorf("got %d, %v; want 1, danger", n, w)
}
}