diff options
author | Andrey Nering <andrey.nering@gmail.com> | 2016-01-31 14:19:02 -0200 |
---|---|---|
committer | Andrey Nering <andrey.nering@gmail.com> | 2016-02-04 18:21:47 -0200 |
commit | 2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1 (patch) | |
tree | 5d09fae4e0f0be52ec38437070433623c89f7006 /models/git_diff.go | |
parent | 137a49e8342ab207c8570fc18b7c81b5fa9789ab (diff) | |
download | gitea-2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1.tar.gz gitea-2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1.zip |
Enable sintax highlighting on diff view. Close #733
Diffstat (limited to 'models/git_diff.go')
-rw-r--r-- | models/git_diff.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/models/git_diff.go b/models/git_diff.go index e8bfe61027..9796ef59f8 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -26,6 +26,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/process" + "github.com/gogits/gogs/modules/template/highlight" ) type DiffLineType uint8 @@ -160,12 +161,20 @@ type DiffFile struct { IsBin bool IsRenamed bool Sections []*DiffSection + HighlightClass string } func (diffFile *DiffFile) GetType() int { return int(diffFile.Type) } +func (diffFile *DiffFile) GetHighlightClass() string { + if diffFile.HighlightClass == "" { + diffFile.HighlightClass = highlight.FileNameToHighlightClass(diffFile.Name) + } + return diffFile.HighlightClass +} + type Diff struct { TotalAddition, TotalDeletion int Files []*DiffFile |