ShortenCommand creates a short identifier for bash commands in workflow logs. It replaces newlines with spaces and truncates to 20 characters if needed. This is a domain-specific function for workflow log parsing. It creates unique identifiers for bash commands by: - Replacing newlines with spaces
(command string)
| 139 | // For general-purpose string truncation with configurable length, |
| 140 | // use stringutil.Truncate instead. |
| 141 | func ShortenCommand(command string) string { |
| 142 | // Take first 20 characters and remove newlines |
| 143 | shortened := strings.ReplaceAll(command, "\n", " ") |
| 144 | if len(shortened) > 20 { |
| 145 | shortened = shortened[:20] + "..." |
| 146 | } |
| 147 | return shortened |
| 148 | } |
| 149 | |
| 150 | // escapeYAMLSingleQuoted escapes single quotes for YAML single-quoted scalars by doubling each |
| 151 | // apostrophe per YAML 1.2. |
no outgoing calls