Skip to content

Commit 6a06c1b

Browse files
committed
fix
1 parent 390d270 commit 6a06c1b

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

Diff for: services/gitdiff/gitdiff.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader, ski
474474
sb := strings.Builder{}
475475

476476
// OK let's set a reasonable buffer size.
477-
// This should be let's say at least the size of maxLineCharacters or 4096 whichever is larger.
477+
// This should be at least the size of maxLineCharacters or 4096 whichever is larger.
478478
readerSize := maxLineCharacters
479479
if readerSize < 4096 {
480480
readerSize = 4096

Diff for: templates/repo/diff/section_unified.tmpl

+33-30
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{$file := .file}}
22
{{range $j, $section := $file.Sections}}
33
{{range $k, $line := $section.Lines}}
4-
{{if or $.root.AfterCommitID (ne .GetType 4)}}
5-
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType}}">
6-
{{if eq .GetType 4}}
4+
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType}}">
5+
{{if eq .GetType 4}}
6+
{{if $.root.AfterCommitID}}
77
<td colspan="2" class="lines-num">
88
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
99
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
@@ -22,35 +22,38 @@
2222
{{end}}
2323
</td>
2424
{{else}}
25-
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td>
26-
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td>
25+
{{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}}
26+
<td colspan="2" class="lines-num"></td>
2727
{{end}}
28-
{{$inlineDiff := $section.GetComputedInlineDiffFor $line $.root.locale -}}
29-
<td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}</td>
30-
<td class="lines-type-marker"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
31-
{{if eq .GetType 4}}
32-
<td class="chroma lines-code blob-hunk">{{/*
33-
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
34-
*/}}</td>
35-
{{else}}
36-
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
37-
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
38-
*/}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
39-
*/}}{{svg "octicon-plus"}}{{/*
40-
*/}}</a>{{/*
41-
*/}}{{end}}{{/*
42-
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
43-
*/}}</td>
44-
{{end}}
45-
</tr>
46-
{{if gt (len $line.Comments) 0}}
47-
<tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}">
48-
<td colspan="3" class="lines-num"></td>
49-
<td class="add-comment-left add-comment-right" colspan="5">
50-
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
51-
</td>
52-
</tr>
28+
{{else}}
29+
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td>
30+
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td>
31+
{{end}}
32+
{{$inlineDiff := $section.GetComputedInlineDiffFor $line $.root.locale -}}
33+
<td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}</td>
34+
<td class="lines-type-marker"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
35+
{{if eq .GetType 4}}
36+
<td class="chroma lines-code blob-hunk">{{/*
37+
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
38+
*/}}</td>
39+
{{else}}
40+
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
41+
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
42+
*/}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
43+
*/}}{{svg "octicon-plus"}}{{/*
44+
*/}}</a>{{/*
45+
*/}}{{end}}{{/*
46+
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
47+
*/}}</td>
5348
{{end}}
49+
</tr>
50+
{{if gt (len $line.Comments) 0}}
51+
<tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}">
52+
<td colspan="3" class="lines-num"></td>
53+
<td class="add-comment-left add-comment-right" colspan="5">
54+
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
55+
</td>
56+
</tr>
5457
{{end}}
5558
{{end}}
5659
{{end}}

Diff for: templates/repo/editor/diff_preview.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="diff-file-box">
22
<div class="ui attached table segment">
3-
<div class="file-body file-code code-view code-diff-unified unicode-escaped">
3+
<div class="file-body file-code code-diff code-diff-unified unicode-escaped">
44
<table>
55
<tbody>
66
{{template "repo/diff/section_unified" dict "file" .File "root" $}}

0 commit comments

Comments
 (0)