@@ -19,6 +19,7 @@ import (
1919const (
2020 DescriptionRepositoryOwner = "Repository owner"
2121 DescriptionRepositoryName = "Repository name"
22+ maxJobLogLines = 50000
2223)
2324
2425// ListWorkflows creates a tool to list workflows in a repository
@@ -757,9 +758,8 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
757758 tailLines = 1000
758759 }
759760
760- const maxLines = 50000
761-
762- lines := make ([]string , maxLines )
761+ lines := make ([]string , maxJobLogLines )
762+ validLines := make ([]bool , maxJobLogLines )
763763 totalLines := 0
764764 writeIndex := 0
765765
@@ -771,7 +771,8 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
771771 totalLines ++
772772
773773 lines [writeIndex ] = line
774- writeIndex = (writeIndex + 1 ) % maxLines
774+ validLines [writeIndex ] = true
775+ writeIndex = (writeIndex + 1 ) % maxJobLogLines
775776 }
776777
777778 if err := scanner .Err (); err != nil {
@@ -780,18 +781,18 @@ func downloadLogContent(logURL string, tailLines int) (string, int, *http.Respon
780781
781782 var result []string
782783 linesInBuffer := totalLines
783- if linesInBuffer > maxLines {
784- linesInBuffer = maxLines
784+ if linesInBuffer > maxJobLogLines {
785+ linesInBuffer = maxJobLogLines
785786 }
786787
787788 startIndex := 0
788- if totalLines > maxLines {
789+ if totalLines > maxJobLogLines {
789790 startIndex = writeIndex
790791 }
791792
792793 for i := 0 ; i < linesInBuffer ; i ++ {
793- idx := (startIndex + i ) % maxLines
794- if lines [idx ] != "" {
794+ idx := (startIndex + i ) % maxJobLogLines
795+ if validLines [idx ] {
795796 result = append (result , lines [idx ])
796797 }
797798 }
0 commit comments