firstLine returns the first non-empty trimmed line of git output, so a stray trailing newline or an unexpected second line never pollutes a resolved SHA.
(out string)
| 554 | // firstLine returns the first non-empty trimmed line of git output, so a stray |
| 555 | // trailing newline or an unexpected second line never pollutes a resolved SHA. |
| 556 | func firstLine(out string) string { |
| 557 | for _, line := range strings.Split(out, "\n") { |
| 558 | if s := strings.TrimSpace(line); s != "" { |
| 559 | return s |
| 560 | } |
| 561 | } |
| 562 | return "" |
| 563 | } |
| 564 | |
| 565 | // workspaceTrackedDiff returns the tracked-file diff, git's stderr, and the |
| 566 | // failure if there was one. Stderr is returned separately so the caller can |
no outgoing calls