From: Lunny Xiao Date: Wed, 26 Mar 2014 10:02:08 +0000 (+0800) Subject: improved diff X-Git-Tag: v0.9.99~2317 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3a27a0c1462302c668168e77497339863f3576cc;p=gitea.git improved diff --- diff --git a/models/git.go b/models/git.go index 5b2a4060b4..6df8d4ec91 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 2627c9e1aa..c05f4d2ffd 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -63,7 +63,8 @@
- {{range .Content}} + {{range .Sections}} + {{range .Lines}} {{end}} + {{end}}
@@ -72,10 +73,11 @@ -
{{.}}
+
{{.Content}}