Archived
Count failed loads as danger in hidden issues
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user