fix the trimming of log filenames for gh run view

This commit is contained in:
benebsiny 2024-08-18 16:57:19 +08:00
parent 1886fb46ab
commit 64415df08d
3 changed files with 13 additions and 0 deletions

View file

@ -546,6 +546,7 @@ func logFilenameRegexp(job shared.Job, step shared.Step) *regexp.Regexp {
// * Truncate long job names
//
sanitizedJobName := strings.ReplaceAll(job.Name, "/", "")
sanitizedJobName = strings.ReplaceAll(sanitizedJobName, ":", "")
sanitizedJobName = truncateAsUTF16(sanitizedJobName, JOB_NAME_MAX_LENGTH)
re := fmt.Sprintf(`^%s\/%d_.*\.txt`, regexp.QuoteMeta(sanitizedJobName), step.Number)
return regexp.MustCompile(re)

View file

@ -1522,6 +1522,18 @@ func Test_attachRunLog(t *testing.T) {
// not the double space in the dir name, as the slash has been removed
wantFilename: "cool job with slash/1_fob the barz.txt",
},
{
name: "job name with colon matches dir with colon removed",
job: shared.Job{
Name: "cool job : with colon",
Steps: []shared.Step{{
Name: "fob the barz",
Number: 1,
}},
},
wantMatch: true,
wantFilename: "cool job with colon/1_fob the barz.txt",
},
{
name: "Job name with really long name (over the ZIP limit)",
job: shared.Job{