MCPcopy Index your code
hub / github.com/cli/cli / relativeFilePath

Function relativeFilePath

pkg/cmd/agent-task/shared/log.go:387–401  ·  view source on GitHub ↗

relativeFilePath converts an absolute file path to a relative one. We expect paths to be of the form: /home/runner/work/ / /path/to/file The expected output of that example is: path/to/file

(absPath string)

Source from the content-addressed store, hash-verified

385// We expect paths to be of the form: /home/runner/work/<repo-owner>/<repo-name>/path/to/file
386// The expected output of that example is: path/to/file
387func relativeFilePath(absPath string) string {
388 relPath := strings.TrimPrefix(absPath, "/home/runner/work/")
389
390 parts := strings.Split(relPath, "/")
391
392 // The last two parts of the path are the
393 // repo name and the repo owner.
394 // If that's all we have (or less),
395 // we return a friendly name "repository".
396 if len(parts) > 2 {
397 // Drop the repo owner and name, returning the remaining path.
398 return strings.Join(parts[2:], "/")
399 }
400 return "repository"
401}
402
403func unmarshal[T any](raw string) *T {
404 var t T

Callers 1

renderLogEntryFunction · 0.85

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected