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

Function ParseDiffText

internal/diff/parser.go:98–106  ·  view source on GitHub ↗

ParseDiffText splits the unified diff text into per-file Diff structs. ref, if non-empty, is a git ref used to read new-file content via git show instead of reading from the working tree. runner, if non-nil, is used to execute git subprocesses through a shared concurrency limiter.

(ctx context.Context, diffText string, repoDir string, ref string, runner *gitcmd.Runner)

Source from the content-addressed store, hash-verified

96// runner, if non-nil, is used to execute git subprocesses through a
97// shared concurrency limiter.
98func ParseDiffText(ctx context.Context, diffText string, repoDir string, ref string, runner *gitcmd.Runner) ([]model.Diff, error) {
99 ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
100 defer cancel()
101 diffs := ParsePatch(diffText)
102 for index := range diffs {
103 finalizeDiff(ctx, &diffs[index], repoDir, ref, runner)
104 }
105 return diffs, nil
106}
107
108func ParsePatch(diffText string) []model.Diff {
109 lines := splitDiffLines(diffText)

Calls 3

ParsePatchFunction · 0.85
finalizeDiffFunction · 0.85
WithTimeoutMethod · 0.80