Skip to content

Commit 34b2162

Browse files
Loutrosilverwindzeripath
authored
Display specific message if diff is not displayed because of too long line (#15611)
* 7184- message if line too long * Update options/locale/locale_en-US.ini Co-authored-by: silverwind <[email protected]> * add flag on missing cases Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
1 parent 1cd3017 commit 34b2162

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@ diff.file_image_width = Width
18871887
diff.file_image_height = Height
18881888
diff.file_byte_size = Size
18891889
diff.file_suppressed = File diff suppressed because it is too large
1890+
diff.file_suppressed_line_too_long = File diff suppressed because one or more lines are too long
18901891
diff.too_many_files = Some files were not shown because too many files changed in this diff
18911892
diff.comment.placeholder = Leave a comment
18921893
diff.comment.markdown_info = Styling with markdown is supported.

services/gitdiff/gitdiff.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,21 +574,22 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem
574574

575575
// DiffFile represents a file diff.
576576
type DiffFile struct {
577-
Name string
578-
OldName string
579-
Index int
580-
Addition, Deletion int
581-
Type DiffFileType
582-
IsCreated bool
583-
IsDeleted bool
584-
IsBin bool
585-
IsLFSFile bool
586-
IsRenamed bool
587-
IsAmbiguous bool
588-
IsSubmodule bool
589-
Sections []*DiffSection
590-
IsIncomplete bool
591-
IsProtected bool
577+
Name string
578+
OldName string
579+
Index int
580+
Addition, Deletion int
581+
Type DiffFileType
582+
IsCreated bool
583+
IsDeleted bool
584+
IsBin bool
585+
IsLFSFile bool
586+
IsRenamed bool
587+
IsAmbiguous bool
588+
IsSubmodule bool
589+
Sections []*DiffSection
590+
IsIncomplete bool
591+
IsIncompleteLineTooLong bool
592+
IsProtected bool
592593
}
593594

594595
// GetType returns type of diff file.
@@ -935,6 +936,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
935936
for {
936937
for isFragment {
937938
curFile.IsIncomplete = true
939+
curFile.IsIncompleteLineTooLong = true
938940
_, isFragment, err = input.ReadLine()
939941
if err != nil {
940942
// Now by the definition of ReadLine this cannot be io.EOF
@@ -1062,6 +1064,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
10621064
line := string(lineBytes)
10631065
if isFragment {
10641066
curFile.IsIncomplete = true
1067+
curFile.IsIncompleteLineTooLong = true
10651068
for isFragment {
10661069
lineBytes, isFragment, err = input.ReadLine()
10671070
if err != nil {
@@ -1073,6 +1076,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio
10731076
}
10741077
if len(line) > maxLineCharacters {
10751078
curFile.IsIncomplete = true
1079+
curFile.IsIncompleteLineTooLong = true
10761080
line = line[:maxLineCharacters]
10771081
}
10781082
curSection.Lines[len(curSection.Lines)-1].Content = line

templates/repo/diff/box.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@
5353
</div>
5454
<span class="file mono">{{$file.Name}}</span>
5555
<div class="diff-file-header-actions df ac">
56-
<div class="text grey">{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
56+
<div class="text grey">
57+
{{if $file.IsIncompleteLineTooLong}}
58+
{{$.i18n.Tr "repo.diff.file_suppressed_line_too_long"}}
59+
{{else}}
60+
{{$.i18n.Tr "repo.diff.file_suppressed"}}
61+
{{end}}
62+
</div>
5763
{{if $file.IsProtected}}
5864
<span class="ui basic label">{{$.i18n.Tr "repo.diff.protected"}}</span>
5965
{{end}}

0 commit comments

Comments
 (0)