MCPcopy Create free account
hub / github.com/cli/cli / getJobNameForLogFilename

Function getJobNameForLogFilename

pkg/cmd/run/view/logs.go:240–256  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

238const JOB_NAME_MAX_LENGTH = 90
239
240func getJobNameForLogFilename(name string) string {
241 // As described in https://github.com/cli/cli/issues/5011#issuecomment-1570713070, there are a number of steps
242 // the server can take when producing the downloaded zip file that can result in a mismatch between the job name
243 // and the filename in the zip including:
244 // * Removing characters in the job name that aren't allowed in file paths
245 // * Truncating names that are too long for zip files
246 // * Adding collision deduplicating numbers for jobs with the same name
247 //
248 // We are hesitant to duplicate all the server logic due to the fragility but it may be unavoidable. Currently, we:
249 // * Strip `/` which occur when composite action job names are constructed of the form `<JOB_NAME`> / <ACTION_NAME>`
250 // * Truncate long job names
251 //
252 sanitizedJobName := strings.ReplaceAll(name, "/", "")
253 sanitizedJobName = strings.ReplaceAll(sanitizedJobName, ":", "")
254 sanitizedJobName = truncateAsUTF16(sanitizedJobName, JOB_NAME_MAX_LENGTH)
255 return sanitizedJobName
256}
257
258// A job run log file is a top-level .txt file whose name starts with an ordinal
259// number; e.g., "0_jobname.txt".

Callers 3

jobLogFilenameRegexpFunction · 0.85
stepLogFilenameRegexpFunction · 0.85

Calls 1

truncateAsUTF16Function · 0.85

Tested by

no test coverage detected