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

Function getJobNameForLogFilename

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

Source from the content-addressed store, hash-verified

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