Skip to content

Commit 5513791

Browse files
Copilotawalsh128
authored andcommitted
fix: handle apt showpkg warnings
1 parent fe5b289 commit 5513791

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/cmd/apt_query/testlogs/testnormalizedlist_virtualpackagesexists_stdoutsconcretepackage.log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ EXECUTION-OBJ-END
1111
2025/03/15 22:29:14 EXECUTION-OBJ-START
1212
{
1313
"Cmd": "apt-cache showpkg libvips",
14-
"Stdout": "libvips42 8.9.1-2 (= )\n",
14+
"Stdout": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
1515
"Stderr": "",
16-
"CombinedOut": "libvips42 8.9.1-2 (= )\n",
16+
"CombinedOut": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
1717
"ExitCode": 0
1818
}
1919
EXECUTION-OBJ-END

src/internal/common/apt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func getNonVirtualPackage(executor exec.Executor, name string) (pkg *AptPackage,
5353
if !inReverseProvides || strings.HasPrefix(trimmed, "W: ") || isErrLine(trimmed) {
5454
continue
5555
}
56+
if strings.HasSuffix(trimmed, ":") {
57+
break
58+
}
5659
splitLine := GetSplitLine(trimmed, " ", 3)
5760
if len(splitLine.Words) < 2 {
5861
continue

src/internal/common/apt_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
execpkg "awalsh128.com/cache-apt-pkgs-action/src/internal/exec"
99
)
1010

11-
type stubExecutor struct {
11+
type mockExecutor struct {
1212
executions map[string]*execpkg.Execution
1313
}
1414

15-
func (s stubExecutor) Exec(name string, arg ...string) *execpkg.Execution {
15+
func (s mockExecutor) Exec(name string, arg ...string) *execpkg.Execution {
1616
cmd := name + " " + strings.Join(arg, " ")
1717
execution, ok := s.executions[cmd]
1818
if !ok {
@@ -21,8 +21,8 @@ func (s stubExecutor) Exec(name string, arg ...string) *execpkg.Execution {
2121
return execution
2222
}
2323

24-
func TestGetNonVirtualPackage_IgnoresWarningsAfterReverseProvides(t *testing.T) {
25-
executor := stubExecutor{
24+
func TestGetNonVirtualPackage_WithWarningsInReverseProvides(t *testing.T) {
25+
executor := mockExecutor{
2626
executions: map[string]*execpkg.Execution{
2727
"apt-cache showpkg libopenblas0-openmp": {
2828
Cmd: "apt-cache showpkg libopenblas0-openmp",

0 commit comments

Comments
 (0)