From cf9b9d3f140a912f07434040c95d53b9ae21f71f Mon Sep 17 00:00:00 2001 From: Loutro Date: Sun, 25 Apr 2021 00:14:31 +0200 Subject: [PATCH 1/3] 7184- message if line too long --- options/locale/locale_en-US.ini | 1 + services/gitdiff/gitdiff.go | 32 +++++++++++++++++--------------- templates/repo/diff/box.tmpl | 8 +++++++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 1a8d253749cf5..a6f8a4c248732 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1886,6 +1886,7 @@ diff.file_image_width = Width diff.file_image_height = Height diff.file_byte_size = Size diff.file_suppressed = File diff suppressed because it is too large +diff.file_suppressed_line_too_long = File diff suppressed because at least one line is too long diff.too_many_files = Some files were not shown because too many files changed in this diff diff.comment.placeholder = Leave a comment diff.comment.markdown_info = Styling with markdown is supported. diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 2ca6bd957ecc4..f926b9497dd06 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -574,21 +574,22 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem // DiffFile represents a file diff. type DiffFile struct { - Name string - OldName string - Index int - Addition, Deletion int - Type DiffFileType - IsCreated bool - IsDeleted bool - IsBin bool - IsLFSFile bool - IsRenamed bool - IsAmbiguous bool - IsSubmodule bool - Sections []*DiffSection - IsIncomplete bool - IsProtected bool + Name string + OldName string + Index int + Addition, Deletion int + Type DiffFileType + IsCreated bool + IsDeleted bool + IsBin bool + IsLFSFile bool + IsRenamed bool + IsAmbiguous bool + IsSubmodule bool + Sections []*DiffSection + IsIncomplete bool + IsIncompleteLineTooLong bool + IsProtected bool } // GetType returns type of diff file. @@ -1073,6 +1074,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio } if len(line) > maxLineCharacters { curFile.IsIncomplete = true + curFile.IsIncompleteLineTooLong = true line = line[:maxLineCharacters] } curSection.Lines[len(curSection.Lines)-1].Content = line diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 4408d5257566b..9a2f7bdd7fed0 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -53,7 +53,13 @@ {{$file.Name}}
-
{{$.i18n.Tr "repo.diff.file_suppressed"}}
+
+ {{if $file.IsIncompleteLineTooLong}} + {{$.i18n.Tr "repo.diff.file_suppressed_line_too_long"}} + {{else}} + {{$.i18n.Tr "repo.diff.file_suppressed"}} + {{end}} +
{{if $file.IsProtected}} {{$.i18n.Tr "repo.diff.protected"}} {{end}} From 7ffb5b4effe2ea9067b3642b21dc3ff79bd6398f Mon Sep 17 00:00:00 2001 From: Loutro Date: Tue, 27 Apr 2021 00:31:36 +0200 Subject: [PATCH 2/3] Update options/locale/locale_en-US.ini Co-authored-by: silverwind --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a6f8a4c248732..bc3b88a0a5e47 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1886,7 +1886,7 @@ diff.file_image_width = Width diff.file_image_height = Height diff.file_byte_size = Size diff.file_suppressed = File diff suppressed because it is too large -diff.file_suppressed_line_too_long = File diff suppressed because at least one line is too long +diff.file_suppressed_line_too_long = File diff suppressed because one or more lines are too long diff.too_many_files = Some files were not shown because too many files changed in this diff diff.comment.placeholder = Leave a comment diff.comment.markdown_info = Styling with markdown is supported. From 263f33c9ac7b9556d0fb77bf8326019b69ccfddf Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 1 May 2021 11:08:11 +0100 Subject: [PATCH 3/3] add flag on missing cases Signed-off-by: Andrew Thornton --- services/gitdiff/gitdiff.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index f926b9497dd06..f8f0fd7e3b90b 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -936,6 +936,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio for { for isFragment { curFile.IsIncomplete = true + curFile.IsIncompleteLineTooLong = true _, isFragment, err = input.ReadLine() if err != nil { // Now by the definition of ReadLine this cannot be io.EOF @@ -1063,6 +1064,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio line := string(lineBytes) if isFragment { curFile.IsIncomplete = true + curFile.IsIncompleteLineTooLong = true for isFragment { lineBytes, isFragment, err = input.ReadLine() if err != nil {