File tree 6 files changed +20
-21
lines changed
6 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,6 @@ func NewFuncMap() template.FuncMap {
179
179
180
180
// -----------------------------------------------------------------
181
181
// misc
182
- "DiffLineTypeToStr" : DiffLineTypeToStr ,
183
182
"ShortSha" : base .ShortSha ,
184
183
"ActionContent2Commits" : ActionContent2Commits ,
185
184
"IsMultilineCommitMessage" : IsMultilineCommitMessage ,
Original file line number Diff line number Diff line change @@ -122,19 +122,6 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
122
122
return push
123
123
}
124
124
125
- // DiffLineTypeToStr returns diff line type name
126
- func DiffLineTypeToStr (diffType int ) string {
127
- switch diffType {
128
- case 2 :
129
- return "add"
130
- case 3 :
131
- return "del"
132
- case 4 :
133
- return "tag"
134
- }
135
- return "same"
136
- }
137
-
138
125
// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
139
126
func MigrationIcon (hostname string ) string {
140
127
switch hostname {
Original file line number Diff line number Diff line change @@ -104,6 +104,19 @@ func (d *DiffLine) GetType() int {
104
104
return int (d .Type )
105
105
}
106
106
107
+ // GetHTMLDiffLineType returns the diff line type name for HTML
108
+ func (d * DiffLine ) GetHTMLDiffLineType () string {
109
+ switch d .Type {
110
+ case DiffLineAdd :
111
+ return "add"
112
+ case DiffLineDel :
113
+ return "del"
114
+ case DiffLineSection :
115
+ return "tag"
116
+ }
117
+ return "same"
118
+ }
119
+
107
120
// CanComment returns whether a line can get commented
108
121
func (d * DiffLine ) CanComment () bool {
109
122
return len (d .Comments ) == 0 && d .Type != DiffLineSection
Original file line number Diff line number Diff line change 1
1
{{if $.IsSplitStyle}}
2
2
{{range $k, $line := $.section.Lines}}
3
- <tr class="{{DiffLineTypeToStr .GetType }}-code nl-{{$k}} ol-{{$k}}">
3
+ <tr class="{{.GetHTMLDiffLineType }}-code nl-{{$k}} ol-{{$k}}">
4
4
{{if eq .GetType 4}}
5
5
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}">
6
6
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
44
44
{{end}}
45
45
{{else}}
46
46
{{range $k, $line := $.section.Lines}}
47
- <tr class="{{DiffLineTypeToStr .GetType }}-code nl-{{$k}} ol-{{$k}}">
47
+ <tr class="{{.GetHTMLDiffLineType }}-code nl-{{$k}} ol-{{$k}}">
48
48
{{if eq .GetType 4}}
49
49
<td colspan="2" class="lines-num">
50
50
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
Original file line number Diff line number Diff line change 13
13
{{range $k, $line := $section.Lines}}
14
14
{{$hasmatch := ne $line.Match -1}}
15
15
{{if or (ne .GetType 2) (not $hasmatch)}}
16
- <tr class="{{DiffLineTypeToStr .GetType }}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType }}">
16
+ <tr class="{{.GetHTMLDiffLineType }}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType }}">
17
17
{{if eq .GetType 4}}
18
18
<td class="lines-num lines-num-old">
19
19
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
107
107
{{if and (eq .GetType 3) $hasmatch}}
108
108
{{$match := index $section.Lines $line.Match}}
109
109
{{if or (gt (len $line.Comments) 0) (gt (len $match.Comments) 0)}}
110
- <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType }}">
110
+ <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType }}">
111
111
<td class="add-comment-left" colspan="4">
112
112
{{if gt (len $line.Comments) 0}}
113
113
{{if eq $line.GetCommentSide "previous"}}
133
133
</tr>
134
134
{{end}}
135
135
{{else if gt (len $line.Comments) 0}}
136
- <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType }}">
136
+ <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType }}">
137
137
<td class="add-comment-left" colspan="4">
138
138
{{if gt (len $line.Comments) 0}}
139
139
{{if eq $line.GetCommentSide "previous"}}
Original file line number Diff line number Diff line change 8
8
</colgroup>
9
9
{{range $j, $section := $file.Sections}}
10
10
{{range $k, $line := $section.Lines}}
11
- <tr class="{{DiffLineTypeToStr .GetType }}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType }}">
11
+ <tr class="{{.GetHTMLDiffLineType }}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType }}">
12
12
{{if eq .GetType 4}}
13
13
{{if $.root.AfterCommitID}}
14
14
<td colspan="2" class="lines-num">
55
55
{{end}}
56
56
</tr>
57
57
{{if gt (len $line.Comments) 0}}
58
- <tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType }}">
58
+ <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType }}">
59
59
<td class="add-comment-left add-comment-right" colspan="5">
60
60
{{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
61
61
</td>
You can’t perform that action at this time.
0 commit comments