@@ -19,6 +19,7 @@ import (
19
19
const (
20
20
DescriptionRepositoryOwner = "Repository owner"
21
21
DescriptionRepositoryName = "Repository name"
22
+ maxJobLogLines = 50000
22
23
)
23
24
24
25
// ListWorkflows creates a tool to list workflows in a repository
@@ -757,9 +758,8 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
757
758
tailLines = 1000
758
759
}
759
760
760
- const maxLines = 50000
761
-
762
- lines := make ([]string , maxLines )
761
+ lines := make ([]string , maxJobLogLines )
762
+ validLines := make ([]bool , maxJobLogLines )
763
763
totalLines := 0
764
764
writeIndex := 0
765
765
@@ -771,7 +771,8 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
771
771
totalLines ++
772
772
773
773
lines [writeIndex ] = line
774
- writeIndex = (writeIndex + 1 ) % maxLines
774
+ validLines [writeIndex ] = true
775
+ writeIndex = (writeIndex + 1 ) % maxJobLogLines
775
776
}
776
777
777
778
if err := scanner .Err (); err != nil {
@@ -780,18 +781,18 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
780
781
781
782
var result []string
782
783
linesInBuffer := totalLines
783
- if linesInBuffer > maxLines {
784
- linesInBuffer = maxLines
784
+ if linesInBuffer > maxJobLogLines {
785
+ linesInBuffer = maxJobLogLines
785
786
}
786
787
787
788
startIndex := 0
788
- if totalLines > maxLines {
789
+ if totalLines > maxJobLogLines {
789
790
startIndex = writeIndex
790
791
}
791
792
792
793
for i := 0 ; i < linesInBuffer ; i ++ {
793
- idx := (startIndex + i ) % maxLines
794
- if lines [idx ] != "" {
794
+ idx := (startIndex + i ) % maxJobLogLines
795
+ if validLines [idx ] {
795
796
result = append (result , lines [idx ])
796
797
}
797
798
}
0 commit comments