diff options
author | Unknwon <u@gogs.io> | 2016-02-07 11:49:11 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-07 11:49:11 -0500 |
commit | f15a2f9b25bbec130915fec5b33c7e49dc7cf57d (patch) | |
tree | 1ba3aa079c4f931a6fef87693cf83e731a323bcc /models/git_diff.go | |
parent | 3b102a71a2cef4a3cdb748bbc6e0499fdec5e3b4 (diff) | |
parent | 2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1 (diff) |
Merge pull request #2528 from andreynering/diff-sintax-highlight-733
Enable syntax highlighting on diff view
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 e8bfe610..9796ef59 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 |