]> source.dussan.org Git - gitea.git/commitdiff
improved diff
authorLunny Xiao <xiaolunwen@gmail.com>
Wed, 26 Mar 2014 10:02:08 +0000 (18:02 +0800)
committerLunny Xiao <xiaolunwen@gmail.com>
Wed, 26 Mar 2014 10:02:08 +0000 (18:02 +0800)
models/git.go
templates/repo/diff.tmpl

index 5b2a4060b43d99962377ac752dc2856a4eacb0fc..6df8d4ec916a535ba0b77e11b8138b232ca0b136 100644 (file)
@@ -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)
index 2627c9e1aa565c0901552fe61fffe2806be83d17..c05f4d2ffda08f9626832821012a9841b395d84a 100644 (file)
@@ -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>
                                 <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>