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

Function firstLine

internal/diff/git.go:549–556  ·  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

547// firstLine returns the first non-empty trimmed line of git output, so a stray
548// trailing newline or an unexpected second line never pollutes a resolved SHA.
549func firstLine(out string) string {
550 for _, line := range strings.Split(out, "\n") {
551 if s := strings.TrimSpace(line); s != "" {
552 return s
553 }
554 }
555 return ""
556}
557
558func (p *Provider) workspaceTrackedDiff(ctx context.Context) (string, error) {
559 out, err := p.runGit(ctx, "-c", "core.quotepath=false", "diff", "--no-ext-diff", "--no-textconv", "--find-renames", "--src-prefix=a/", "--dst-prefix=b/", "--no-color", "-U"+fmt.Sprint(DiffContextLines), "--end-of-options", "HEAD", "--")

Callers 4

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

Calls

no outgoing calls

Tested by 1

TestFirstLineFunction · 0.68