MCPcopy Create free account
hub / github.com/github/gh-aw / ShortenCommand

Function ShortenCommand

pkg/workflow/strings.go:141–148  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

139// For general-purpose string truncation with configurable length,
140// use stringutil.Truncate instead.
141func 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.

Callers 3

TestShortenCommandFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestShortenCommandFunction · 0.68