buildSourceStringWithCommitSHA builds the source string with the actual commit SHA This is used when adding workflows to include the precise commit that was installed
(workflow *WorkflowSpec, commitSHA string)
| 473 | // buildSourceStringWithCommitSHA builds the source string with the actual commit SHA |
| 474 | // This is used when adding workflows to include the precise commit that was installed |
| 475 | func buildSourceStringWithCommitSHA(workflow *WorkflowSpec, commitSHA string) string { |
| 476 | if workflow.RepoSlug == "" || workflow.WorkflowPath == "" { |
| 477 | return "" |
| 478 | } |
| 479 | |
| 480 | if workflow.FromRepositoryManifest { |
| 481 | ref := workflow.Version |
| 482 | if commitSHA != "" { |
| 483 | ref = commitSHA |
| 484 | } |
| 485 | if ref == "" { |
| 486 | return repositoryPackageIdentifier(workflow.RepoSlug, workflow.PackagePath) |
| 487 | } |
| 488 | return repositoryPackageIdentifier(workflow.RepoSlug, workflow.PackagePath) + "@" + ref |
| 489 | } |
| 490 | |
| 491 | // For local workflows, remove the "./" prefix from the WorkflowPath |
| 492 | workflowPath := strings.TrimPrefix(workflow.WorkflowPath, "./") |
| 493 | |
| 494 | // Format: owner/repo/path@commitSHA |
| 495 | source := workflow.RepoSlug + "/" + workflowPath |
| 496 | if commitSHA != "" { |
| 497 | source += "@" + commitSHA |
| 498 | } else if workflow.Version != "" { |
| 499 | // Fallback to the version if no commit SHA is available |
| 500 | source += "@" + workflow.Version |
| 501 | } |
| 502 | |
| 503 | return source |
| 504 | } |
| 505 | |
| 506 | // IsCommitSHA checks if a version string looks like a commit SHA (40-character hex string) |
| 507 | func IsCommitSHA(version string) bool { |