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)
| 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 |
| 387 | func 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 | |
| 403 | func unmarshal[T any](raw string) *T { |
| 404 | var t T |