fix: handle apt showpkg warnings

This commit is contained in:
copilot-swe-agent[bot] 2026-06-13 23:42:58 +00:00 committed by GitHub
parent 47536a99e2
commit c111f07c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View file

@ -11,9 +11,9 @@ EXECUTION-OBJ-END
2025/03/15 22:29:14 EXECUTION-OBJ-START
{
"Cmd": "apt-cache showpkg libvips",
"Stdout": "libvips42 8.9.1-2 (= )\n",
"Stdout": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
"Stderr": "",
"CombinedOut": "libvips42 8.9.1-2 (= )\n",
"CombinedOut": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -53,6 +53,9 @@ func getNonVirtualPackage(executor exec.Executor, name string) (pkg *AptPackage,
if !inReverseProvides || strings.HasPrefix(trimmed, "W: ") || isErrLine(trimmed) {
continue
}
if strings.HasSuffix(trimmed, ":") {
break
}
splitLine := GetSplitLine(trimmed, " ", 3)
if len(splitLine.Words) < 2 {
continue

View file

@ -8,11 +8,11 @@ import (
execpkg "awalsh128.com/cache-apt-pkgs-action/src/internal/exec"
)
type stubExecutor struct {
type mockExecutor struct {
executions map[string]*execpkg.Execution
}
func (s stubExecutor) Exec(name string, arg ...string) *execpkg.Execution {
func (s mockExecutor) Exec(name string, arg ...string) *execpkg.Execution {
cmd := name + " " + strings.Join(arg, " ")
execution, ok := s.executions[cmd]
if !ok {
@ -21,8 +21,8 @@ func (s stubExecutor) Exec(name string, arg ...string) *execpkg.Execution {
return execution
}
func TestGetNonVirtualPackage_IgnoresWarningsAfterReverseProvides(t *testing.T) {
executor := stubExecutor{
func TestGetNonVirtualPackage_WithWarningsInReverseProvides(t *testing.T) {
executor := mockExecutor{
executions: map[string]*execpkg.Execution{
"apt-cache showpkg libopenblas0-openmp": {
Cmd: "apt-cache showpkg libopenblas0-openmp",