diff options
-rw-r--r-- | models/git.go | 2 | ||||
-rw-r--r-- | templates/repo/diff.tmpl | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/models/git.go b/models/git.go index 5b2a4060..6df8d4ec 100644 --- a/models/git.go +++ b/models/git.go @@ -291,6 +291,8 @@ func ParsePatch(reader io.Reader) (*Diff, error) { curSection.Lines = append(curSection.Lines, diffLine) continue } else if line[0] == '@' { + curSection = &DiffSection{} + curFile.Sections = append(curFile.Sections, curSection) ss := strings.Split(line, "@@") diffLine := &DiffLine{Type: SectionLine, Content:"@@ "+ss[len(ss)-2]} curSection.Lines = append(curSection.Lines, diffLine) diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 2627c9e1..c05f4d2f 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -63,7 +63,8 @@ <div class="panel-body file-body file-code code-view code-diff"> <table> <tbody> - {{range .Content}} + {{range .Sections}} + {{range .Lines}} <tr class="same-code nl-1 ol-1"> <td class="lines-num lines-num-old"> <span rel="L1"></span> @@ -72,10 +73,11 @@ <span rel="L1"></span> </td> <td class="lines-code"> - <pre>{{.}}</pre> + <pre>{{.Content}}</pre> </td> </tr> {{end}} + {{end}} <!-- <tr class="same-code nl-2 ol-2"> <td class="lines-num lines-num-old"> <span rel="L1">2</span> |