diff --git a/pkg/cmd/run/view/fixtures/run_log.zip b/pkg/cmd/run/view/fixtures/run_log.zip index 5b0bb1e30..e298df386 100644 Binary files a/pkg/cmd/run/view/fixtures/run_log.zip and b/pkg/cmd/run/view/fixtures/run_log.zip differ diff --git a/pkg/cmd/run/view/view.go b/pkg/cmd/run/view/view.go index c54905422..cc9aa0981 100644 --- a/pkg/cmd/run/view/view.go +++ b/pkg/cmd/run/view/view.go @@ -503,7 +503,7 @@ func logFilenameRegexp(job shared.Job, step shared.Step) *regexp.Regexp { // constructs a job name by constructing a job name of ` / `. This means that logs will // never be found for jobs that use composite actions. sanitizedJobName := strings.ReplaceAll(job.Name, "/", "") - re := fmt.Sprintf(`%s\/%d_.*\.txt`, regexp.QuoteMeta(sanitizedJobName), step.Number) + re := fmt.Sprintf(`^%s\/%d_.*\.txt`, regexp.QuoteMeta(sanitizedJobName), step.Number) return regexp.MustCompile(re) } diff --git a/pkg/cmd/run/view/view_test.go b/pkg/cmd/run/view/view_test.go index 1135212be..1f5d4df75 100644 --- a/pkg/cmd/run/view/view_test.go +++ b/pkg/cmd/run/view/view_test.go @@ -1374,9 +1374,11 @@ func TestViewRun(t *testing.T) { // ├── cool job/ // │ ├── 1_fob the barz.txt // │ └── 2_barz the fob.txt -// └── sad job/ -// ├── 1_barf the quux.txt -// └── 2_quux the barf.txt +// ├── sad job/ +// │ ├── 1_barf the quux.txt +// │ └── 2_quux the barf.txt +// └── ad job/ +// └── 1_barf the quux.txt func Test_attachRunLog(t *testing.T) { tests := []struct { name string @@ -1431,6 +1433,18 @@ func Test_attachRunLog(t *testing.T) { }, wantMatch: false, }, + { + name: "one job name is a suffix of another", + job: shared.Job{ + Name: "ad job", + Steps: []shared.Step{{ + Name: "barf the quux", + Number: 1, + }}, + }, + wantMatch: true, + wantFilename: "ad job/1_barf the quux.txt", + }, { name: "escape metacharacters in job name", job: shared.Job{