| 1 | package gitrepo |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "fmt" |
| 6 | "strings" |
| 7 | ) |
| 8 | |
| 9 | // CommitterTimestamp is de committer-tijd van sha in ISO 8601 (%cI). |
| 10 | // Dat is dezelfde tijd als CI_COMMIT_TIMESTAMP. |
| 11 | func CommitterTimestamp(ctx context.Context, gitBin, dir, sha string) (string, error) { |
| 12 | if sha == "" { |
| 13 | return "", fmt.Errorf("sha ontbreekt") |
| 14 | } |
| 15 | out, err := run(ctx, gitBin, nil, "-C", dir, "show", "-s", "--format=%cI", sha) |
| 16 | if err != nil { |
| 17 | return "", err |
| 18 | } |
| 19 | stamp := strings.TrimSpace(out) |
| 20 | if stamp == "" { |
| 21 | return "", fmt.Errorf("geen committer-tijd") |
| 22 | } |
| 23 | return stamp, nil |
| 24 | } |