mirror of
https://github.com/go-gitea/gitea
synced 2025-07-27 04:38:36 +00:00
Backport #34168 by @kerwin612 Co-authored-by: Kerwin Bryant <kerwin612@qq.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -67,7 +68,7 @@ type WebDiffFileItem struct {
|
||||
EntryMode string
|
||||
IsViewed bool
|
||||
Children []*WebDiffFileItem
|
||||
// TODO: add icon support in the future
|
||||
FileIcon template.HTML
|
||||
}
|
||||
|
||||
// WebDiffFileTree is used by frontend, check the field names in frontend before changing
|
||||
@@ -77,7 +78,7 @@ type WebDiffFileTree struct {
|
||||
|
||||
// transformDiffTreeForWeb transforms a gitdiff.DiffTree into a WebDiffFileTree for Web UI rendering
|
||||
// it also takes a map of file names to their viewed state, which is used to mark files as viewed
|
||||
func transformDiffTreeForWeb(diffTree *gitdiff.DiffTree, filesViewedState map[string]pull_model.ViewedState) (dft WebDiffFileTree) {
|
||||
func transformDiffTreeForWeb(renderedIconPool *fileicon.RenderedIconPool, diffTree *gitdiff.DiffTree, filesViewedState map[string]pull_model.ViewedState) (dft WebDiffFileTree) {
|
||||
dirNodes := map[string]*WebDiffFileItem{"": &dft.TreeRoot}
|
||||
addItem := func(item *WebDiffFileItem) {
|
||||
var parentPath string
|
||||
@@ -110,6 +111,7 @@ func transformDiffTreeForWeb(diffTree *gitdiff.DiffTree, filesViewedState map[st
|
||||
item := &WebDiffFileItem{FullName: file.HeadPath, DiffStatus: file.Status}
|
||||
item.IsViewed = filesViewedState[item.FullName] == pull_model.Viewed
|
||||
item.NameHash = git.HashFilePathForWebUI(item.FullName)
|
||||
item.FileIcon = fileicon.RenderEntryIconHTML(renderedIconPool, &fileicon.EntryInfo{FullName: file.HeadPath, EntryMode: file.HeadMode})
|
||||
|
||||
switch file.HeadMode {
|
||||
case git.EntryModeTree:
|
||||
|
Reference in New Issue
Block a user