MCPcopy
hub / github.com/go-task/task / ReadContext

Method ReadContext

taskfile/node_git.go:161–187  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

159}
160
161func (node *GitNode) ReadContext(ctx context.Context) ([]byte, error) {
162 // Get or clone the repository into cache
163 repoDir, err := node.getOrCloneRepo(ctx)
164 if err != nil {
165 return nil, err
166 }
167
168 // Build path to Taskfile in the cached repo
169 // If node.path is empty, search in repo root; otherwise search in the specified path
170 // fsext.SearchPath handles both files and directories (searching for DefaultTaskfiles)
171 searchPath := repoDir
172 if node.path != "" {
173 searchPath = filepath.Join(repoDir, node.path)
174 }
175 filePath, err := fsext.SearchPath(searchPath, DefaultTaskfiles)
176 if err != nil {
177 return nil, err
178 }
179
180 // Read file from cached repo
181 b, err := os.ReadFile(filePath)
182 if err != nil {
183 return nil, err
184 }
185
186 return b, nil
187}
188
189func (node *GitNode) ResolveEntrypoint(entrypoint string) (string, error) {
190 // If the file is remote, we don't need to resolve the path

Callers 1

ReadMethod · 0.95

Calls 2

getOrCloneRepoMethod · 0.95
SearchPathFunction · 0.92

Tested by

no test coverage detected