MCPcopy Create free account
hub / github.com/alibaba/open-code-review / firstLine

Function firstLine

internal/diff/git.go:616–623  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

614// firstLine returns the first non-empty trimmed line of git output, so a stray
615// trailing newline or an unexpected second line never pollutes a resolved SHA.
616func firstLine(out string) string {
617 for _, line := range strings.Split(out, "\n") {
618 if s := strings.TrimSpace(line); s != "" {
619 return s
620 }
621 }
622 return ""
623}
624
625// workspaceTrackedDiff returns the tracked-file diff, git's stderr, and the
626// failure if there was one. Stderr is returned separately so the caller can

Callers 4

RemoteIdentityMethod · 0.85
resolveCommitMethod · 0.85
commitParentsMethod · 0.85
TestFirstLineFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestFirstLineFunction · 0.68