extractExperimentName extracts the workflow ID from a branch ref. "origin/experiments/my-workflow" → "my-workflow" "experiments/my-workflow" → "my-workflow" "experiments/" → "" (bare prefix, rejected by callers)
(ref string)
| 744 | // "experiments/my-workflow" → "my-workflow" |
| 745 | // "experiments/" → "" (bare prefix, rejected by callers) |
| 746 | func extractExperimentName(ref string) string { |
| 747 | ref = strings.TrimPrefix(ref, "origin/") |
| 748 | if !strings.HasPrefix(ref, experimentsBranchPrefix) { |
| 749 | return "" |
| 750 | } |
| 751 | // An empty result here (bare "experiments/" ref) is acceptable: callers |
| 752 | // guard against empty workflow IDs with `if workflowID == ""` checks. |
| 753 | return strings.TrimPrefix(ref, experimentsBranchPrefix) |
| 754 | } |
| 755 | |
| 756 | // gitRefExists reports whether a git ref exists locally. |
| 757 | func gitRefExists(ref string) bool { |
no outgoing calls