From 9fadfe7cde84cbdcb4b338dfc04c244fafd1c514 Mon Sep 17 00:00:00 2001 From: Thomas Miceli Date: Wed, 5 Apr 2023 18:20:50 +0200 Subject: [PATCH] Log parser with maxBytes variable --- internal/git/commands.go | 2 +- internal/git/output_parser.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/git/commands.go b/internal/git/commands.go index df847ba..5dc6eed 100644 --- a/internal/git/commands.go +++ b/internal/git/commands.go @@ -126,7 +126,7 @@ func GetLog(user string, gist string, skip string) ([]*Commit, error) { return nil, err } - return parseLog(stdout), nil + return parseLog(stdout, 2<<18), nil } func CloneTmp(user string, gist string, gistTmpId string, email string) error { diff --git a/internal/git/output_parser.go b/internal/git/output_parser.go index a7fe0ae..e0ca7b7 100644 --- a/internal/git/output_parser.go +++ b/internal/git/output_parser.go @@ -61,7 +61,7 @@ func truncateCommandOutput(out io.Reader, maxBytes int64) (string, bool, error) return string(buf), truncated, nil } -func parseLog(out io.Reader) []*Commit { +func parseLog(out io.Reader, maxBytes int) []*Commit { scanner := bufio.NewScanner(out) var commits []*Commit @@ -164,7 +164,7 @@ func parseLog(out io.Reader) []*Commit { currentFile.Content += string(line) + "\n" bytesRead += len(line) - if bytesRead > 2<<18 { + if bytesRead > maxBytes { currentFile.Truncated = true currentFile.Content = "" isContent = false