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

Method Read

internal/tool/filereader.go:71–80  ·  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

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

Calls 2

readFromDiskMethod · 0.95
readFromGitShowMethod · 0.95