mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
corrected a problem reported by CLAUDE Reviewer
This commit is contained in:
parent
f28b9a5a13
commit
7f67c6a271
3 changed files with 26 additions and 10 deletions
13
CLAUDE.md
13
CLAUDE.md
|
|
@ -149,15 +149,22 @@ GetEvents() - Streaming (socket) or polling (libpod)
|
||||||
- Custom commands configurable via YAML
|
- Custom commands configurable via YAML
|
||||||
- Command templates use Go template syntax
|
- Command templates use Go template syntax
|
||||||
|
|
||||||
|
### GUI Features
|
||||||
|
- **Pod expand/collapse**: Pods can be expanded/collapsed in the containers panel. State tracked in `gui.State.ExpandedPods` map
|
||||||
|
- **Container sorting**: Controlled by `LegacySortContainers` config option:
|
||||||
|
- `false` (default): Sort by state (running → exited → created), then alphabetically
|
||||||
|
- `true`: Sort alphabetically by name only
|
||||||
|
- **Container list items**: `ContainerListItem` wraps both pods and containers for unified list display
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run all tests with coverage
|
# Run all tests with coverage
|
||||||
./test.sh
|
./test.sh
|
||||||
|
|
||||||
# Run specific package tests
|
# Run specific package tests (requires build tags to avoid CGO dependencies)
|
||||||
go test -mod=vendor ./pkg/commands/...
|
go test -tags=containers_image_openpgp,exclude_graphdriver_btrfs -mod=vendor ./pkg/gui/...
|
||||||
go test -mod=vendor ./pkg/gui/...
|
go test -tags=containers_image_openpgp,exclude_graphdriver_btrfs -mod=vendor ./pkg/commands/...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Module Info
|
## Module Info
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ func sortContainers(a *commands.Container, b *commands.Container, legacySort boo
|
||||||
// sortContainerListItems sorts items to group pods with their containers.
|
// sortContainerListItems sorts items to group pods with their containers.
|
||||||
// Order: pods first (sorted alphabetically), then their containers indented (sorted alphabetically),
|
// Order: pods first (sorted alphabetically), then their containers indented (sorted alphabetically),
|
||||||
// then standalone containers (sorted alphabetically).
|
// then standalone containers (sorted alphabetically).
|
||||||
func sortContainerListItems(a *commands.ContainerListItem, b *commands.ContainerListItem, _ bool) bool {
|
func sortContainerListItems(a *commands.ContainerListItem, b *commands.ContainerListItem, legacySort bool) bool {
|
||||||
// Pods and their containers sort before standalone containers
|
// Pods and their containers sort before standalone containers
|
||||||
aInPod := a.IsPod || a.PodID() != ""
|
aInPod := a.IsPod || a.PodID() != ""
|
||||||
bInPod := b.IsPod || b.PodID() != ""
|
bInPod := b.IsPod || b.PodID() != ""
|
||||||
|
|
@ -181,8 +181,17 @@ func sortContainerListItems(a *commands.ContainerListItem, b *commands.Container
|
||||||
return a.Name() < b.Name()
|
return a.Name() < b.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both are standalone containers: sort alphabetically
|
// Both are standalone containers
|
||||||
|
if legacySort {
|
||||||
return a.Name() < b.Name()
|
return a.Name() < b.Name()
|
||||||
|
}
|
||||||
|
// Sort by state, then by name
|
||||||
|
stateA := containerStates[a.State()]
|
||||||
|
stateB := containerStates[b.State()]
|
||||||
|
if stateA == stateB {
|
||||||
|
return a.Name() < b.Name()
|
||||||
|
}
|
||||||
|
return stateA < stateB
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper functions that delegate to container or pod rendering
|
// Wrapper functions that delegate to container or pod rendering
|
||||||
|
|
|
||||||
|
|
@ -250,17 +250,17 @@ func TestSortContainerListItems(t *testing.T) {
|
||||||
return sortContainerListItems(items[i], items[j], false)
|
return sortContainerListItems(items[i], items[j], false)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Expected order:
|
// Expected order (with legacySort=false, sorts by state then name):
|
||||||
// 1. pod alpha (alphabetically first pod)
|
// 1. pod alpha (alphabetically first pod)
|
||||||
// 2. ant (container in alpha, alphabetically first)
|
// 2. ant (container in alpha, alphabetically first)
|
||||||
// 3. bear (container in alpha)
|
// 3. bear (container in alpha)
|
||||||
// 4. pod beta (alphabetically second pod)
|
// 4. pod beta (alphabetically second pod)
|
||||||
// 5. xray (container in beta, alphabetically first)
|
// 5. xray (container in beta, alphabetically first)
|
||||||
// 6. yak (container in beta)
|
// 6. yak (container in beta)
|
||||||
// 7. apple (standalone, alphabetically first)
|
// 7. zebra (standalone, running - state 1)
|
||||||
// 8. zebra (standalone)
|
// 8. apple (standalone, exited - state 2)
|
||||||
|
|
||||||
expectedOrder := []string{"alpha", "ant", "bear", "beta", "xray", "yak", "apple", "zebra"}
|
expectedOrder := []string{"alpha", "ant", "bear", "beta", "xray", "yak", "zebra", "apple"}
|
||||||
|
|
||||||
assert.Equal(t, len(expectedOrder), len(items))
|
assert.Equal(t, len(expectedOrder), len(items))
|
||||||
for i, item := range items {
|
for i, item := range items {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue