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)
| 69 | // - Workspace: reads directly from the filesystem. |
| 70 | // - Range / Commit: uses `git show <Ref>:<path>` to read at the given ref. |
| 71 | func (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 | |
| 82 | func (fr *FileReader) readFromDisk(path string) (string, error) { |
| 83 | fullPath, err := fr.resolveWorkspacePath(path) |