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

Method Read

internal/tool/filereader.go:68–77  ·  view source on GitHub ↗

Read returns the full content of a file path (relative to RepoDir), resolved according to the active review mode. - Workspace: reads directly from the filesystem. - Range / Commit: uses `git show : ` to read at the given ref.

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

66// - Workspace: reads directly from the filesystem.
67// - Range / Commit: uses `git show <Ref>:<path>` to read at the given ref.
68func (fr *FileReader) Read(ctx context.Context, path string) (string, error) {
69 switch fr.Mode {
70 case ModeWorkspace:
71 return fr.readFromDisk(path)
72 case ModeRange, ModeCommit:
73 return fr.readFromGitShow(ctx, path)
74 default:
75 return fr.readFromDisk(path)
76 }
77}
78
79func (fr *FileReader) readFromDisk(path string) (string, error) {
80 fullPath, err := fr.resolveWorkspacePath(path)

Calls 2

readFromDiskMethod · 0.95
readFromGitShowMethod · 0.95