mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-19 19:18:43 +02:00
Fix #35106
This commit is contained in:
parent
693d26914f
commit
99596044d7
@ -20,6 +20,7 @@ const (
|
|||||||
GitlabLanguage = "gitlab-language"
|
GitlabLanguage = "gitlab-language"
|
||||||
Lockable = "lockable"
|
Lockable = "lockable"
|
||||||
Filter = "filter"
|
Filter = "filter"
|
||||||
|
Diff = "diff"
|
||||||
)
|
)
|
||||||
|
|
||||||
var LinguistAttributes = []string{
|
var LinguistAttributes = []string{
|
||||||
|
@ -1239,7 +1239,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
checker, err := attribute.NewBatchChecker(gitRepo, opts.AfterCommitID, []string{attribute.LinguistVendored, attribute.LinguistGenerated, attribute.LinguistLanguage, attribute.GitlabLanguage})
|
checker, err := attribute.NewBatchChecker(gitRepo, opts.AfterCommitID, []string{attribute.LinguistVendored, attribute.LinguistGenerated, attribute.LinguistLanguage, attribute.GitlabLanguage, attribute.Diff})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1248,6 +1248,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
|
|||||||
for _, diffFile := range diff.Files {
|
for _, diffFile := range diff.Files {
|
||||||
isVendored := optional.None[bool]()
|
isVendored := optional.None[bool]()
|
||||||
isGenerated := optional.None[bool]()
|
isGenerated := optional.None[bool]()
|
||||||
|
attrDiff := optional.None[string]()
|
||||||
attrs, err := checker.CheckPath(diffFile.Name)
|
attrs, err := checker.CheckPath(diffFile.Name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
isVendored, isGenerated = attrs.GetVendored(), attrs.GetGenerated()
|
isVendored, isGenerated = attrs.GetVendored(), attrs.GetGenerated()
|
||||||
@ -1255,6 +1256,7 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
|
|||||||
if language.Has() {
|
if language.Has() {
|
||||||
diffFile.Language = language.Value()
|
diffFile.Language = language.Value()
|
||||||
}
|
}
|
||||||
|
attrDiff = attrs.Get(attribute.Diff).ToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate Submodule URLs
|
// Populate Submodule URLs
|
||||||
@ -1276,7 +1278,8 @@ func GetDiffForRender(ctx context.Context, repoLink string, gitRepo *git.Reposit
|
|||||||
diffFile.Sections = append(diffFile.Sections, tailSection)
|
diffFile.Sections = append(diffFile.Sections, tailSection)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !setting.Git.DisableDiffHighlight {
|
shouldFullFileHighlight := !setting.Git.DisableDiffHighlight && attrDiff.Value() == ""
|
||||||
|
if shouldFullFileHighlight {
|
||||||
if limitedContent.LeftContent != nil && limitedContent.LeftContent.buf.Len() < MaxDiffHighlightEntireFileSize {
|
if limitedContent.LeftContent != nil && limitedContent.LeftContent.buf.Len() < MaxDiffHighlightEntireFileSize {
|
||||||
diffFile.highlightedLeftLines = highlightCodeLines(diffFile, true /* left */, limitedContent.LeftContent.buf.String())
|
diffFile.highlightedLeftLines = highlightCodeLines(diffFile, true /* left */, limitedContent.LeftContent.buf.String())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user