Archived
Count failed loads as danger in hidden issues
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,7 @@ Rules:
|
|||||||
`Submodule.HiddenIssues()` counts the issues of **all** loaded descendants
|
`Submodule.HiddenIssues()` counts the issues of **all** loaded descendants
|
||||||
and returns the most severe level. A collapsed submodule shows this as `·k`
|
and returns the most severe level. A collapsed submodule shows this as `·k`
|
||||||
in that level's color, so a danger can never hide inside a collapsed subtree.
|
in that level's color, so a danger can never hide inside a collapsed subtree.
|
||||||
|
A descendant whose load failed (`error`) counts as one danger.
|
||||||
|
|
||||||
## Resolving a pin to a ref
|
## Resolving a pin to a ref
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,14 @@ func (s *Status) Issues() []Issue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HiddenIssues counts the issues of all loaded descendants and returns the
|
// 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) {
|
func (m *Submodule) HiddenIssues() (count int, worst Level) {
|
||||||
Walk(m.Children, func(c *Submodule) {
|
Walk(m.Children, func(c *Submodule) {
|
||||||
|
if c.Status == nil && c.Err != nil {
|
||||||
|
count++
|
||||||
|
worst = max(worst, LevelDanger)
|
||||||
|
}
|
||||||
for _, is := range c.Status.Issues() {
|
for _, is := range c.Status.Issues() {
|
||||||
count++
|
count++
|
||||||
worst = max(worst, is.Level)
|
worst = max(worst, is.Level)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package submodule
|
package submodule
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"slices"
|
"slices"
|
||||||
"testing"
|
"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