Skip to content

Commit 36236f5

Browse files
committed
Address pr feedback
1 parent ec50b5e commit 36236f5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
456456
- `repo`: Repository name (string, required)
457457
- `return_content`: Returns actual log content instead of URLs (boolean, optional)
458458
- `run_id`: Workflow run ID (required when using failed_only) (number, optional)
459+
- `tail_lines`: Number of lines to return from the end of the log (number, optional)
459460

460461
- **get_workflow_run** - Get workflow run
461462
- `owner`: Repository owner (string, required)

pkg/github/actions.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,17 @@ func downloadLogContent(logURL string, tailLines int) (string, *http.Response, e
790790

791791
// Truncate to tail_lines if specified
792792
if tailLines > 0 {
793-
lines := strings.Split(logContent, "\n")
794-
if len(lines) > tailLines {
795-
lines = lines[len(lines)-tailLines:]
796-
logContent = strings.Join(lines, "\n")
793+
lineCount := 0
794+
795+
// Count backwards to find the nth newline from the end
796+
for i := len(logContent) - 1; i >= 0 && lineCount < tailLines; i-- {
797+
if logContent[i] == '\n' {
798+
lineCount++
799+
if lineCount == tailLines {
800+
logContent = logContent[i+1:]
801+
break
802+
}
803+
}
797804
}
798805
}
799806

0 commit comments

Comments
 (0)