MCPcopy
hub / github.com/github/github-mcp-server / downloadLogContent

Function downloadLogContent

pkg/github/actions.go:168–198  ·  view source on GitHub ↗
(ctx context.Context, logURL string, tailLines int, maxLines int)

Source from the content-addressed store, hash-verified

166}
167
168func downloadLogContent(ctx context.Context, logURL string, tailLines int, maxLines int) (string, int, *http.Response, error) {
169 prof := profiler.New(nil, profiler.IsProfilingEnabled())
170 finish := prof.Start(ctx, "log_buffer_processing")
171
172 httpResp, err := http.Get(logURL) //nolint:gosec
173 if err != nil {
174 return "", 0, httpResp, fmt.Errorf("failed to download logs: %w", err)
175 }
176 defer func() { _ = httpResp.Body.Close() }()
177
178 if httpResp.StatusCode != http.StatusOK {
179 return "", 0, httpResp, fmt.Errorf("failed to download logs: HTTP %d", httpResp.StatusCode)
180 }
181
182 bufferSize := min(tailLines, maxLines)
183
184 processedInput, totalLines, httpResp, err := buffer.ProcessResponseAsRingBufferToEnd(httpResp, bufferSize)
185 if err != nil {
186 return "", 0, httpResp, fmt.Errorf("failed to process log content: %w", err)
187 }
188
189 lines := strings.Split(processedInput, "\n")
190 if len(lines) > tailLines {
191 lines = lines[len(lines)-tailLines:]
192 }
193 finalResult := strings.Join(lines, "\n")
194
195 _ = finish(len(lines), int64(len(finalResult)))
196
197 return finalResult, totalLines, httpResp, nil
198}
199
200// ActionsList returns the tool and handler for listing GitHub Actions resources.
201func ActionsList(t translations.TranslationHelperFunc) inventory.ServerTool {

Callers 1

getJobLogDataFunction · 0.85

Calls 5

NewFunction · 0.92
IsProfilingEnabledFunction · 0.92
StartMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected