Improve diff display
gitile/pages.scm
195 | 195 | ||
196 | 196 | (define (project-commit repository-name repo ref) | |
197 | 197 | (let* ((commit (get-commit repo ref)) | |
198 | - | (parent (commit-parent commit))) | |
198 | + | (parent (commit-parent commit)) | |
199 | + | (diff (diff-tree-to-tree repo (commit-tree parent) (commit-tree commit)))) | |
199 | 200 | `(,(commit-infobox repository-name commit #:open? #t) | |
200 | 201 | (p (@ (class "commit-summary")) ,(commit-summary commit)) | |
201 | - | (pre (@ (class "diff")) | |
202 | - | ,(diff->string (diff-tree-to-tree repo (commit-tree parent) | |
203 | - | (commit-tree commit))))))) | |
202 | + | ,(diff-box diff)))) | |
203 | + | ||
204 | + | (define (diff-box diff) | |
205 | + | (let ((content '()) (file-header #f) (file-content #f) (first-hunk #t)) | |
206 | + | (diff-foreach diff | |
207 | + | (lambda (delta progress) | |
208 | + | (pk 'file delta progress) | |
209 | + | (when file-header | |
210 | + | (set! content (append content (cons file-header `((table (@ (class "file-diff")) ,(reverse file-content))))))) | |
211 | + | (set! first-hunk #t) | |
212 | + | (set! file-content '()) | |
213 | + | (cond | |
214 | + | ((equal? (diff-delta-status delta) GIT-DELTA-MODIFIED) | |
215 | + | (set! file-header | |
216 | + | `(p (@ (class "file-name")) ,(diff-file-path (diff-delta-old-file delta))))) | |
217 | + | (else | |
218 | + | (set! file-header | |
219 | + | `(p (@ (class "file-name")) | |
220 | + | ,(diff-file-path (diff-delta-old-file delta)) | |
221 | + | " unknown status " | |
222 | + | ,(number->string (diff-delta-status delta)))))) | |
223 | + | 0) | |
224 | + | (lambda (delta binary) | |
225 | + | (set! file-content `((tr (@ (class "hunk-delim")) (td (@ (colspan 4)) "Binary data")))) | |
226 | + | 0) | |
227 | + | (lambda (delta hunk) | |
228 | + | (if first-hunk | |
229 | + | (set! first-hunk #f) | |
230 | + | (set! file-content | |
231 | + | (append file-content `((tr (@ (class "hunk-delim")) (td (@ (colspan 4)) "???")))))) | |
232 | + | 0) | |
233 | + | (lambda (delta hunk line) | |
234 | + | (let* ((origin (list->string (list (integer->char (diff-line-origin line))))) | |
235 | + | (class (match origin | |
236 | + | ("-" "diff-minus") | |
237 | + | ("+" "diff-plus") | |
238 | + | (_ "")))) | |
239 | + | (let loop ((lines (string-split (diff-line-content line) #\newline)) | |
240 | + | (old-line (diff-line-old-lineno line)) | |
241 | + | (new-line (diff-line-new-lineno line))) | |
242 | + | (match lines | |
243 | + | (() #t) | |
244 | + | (("") #t) | |
245 | + | ((line lines ...) | |
246 | + | (set! file-content | |
247 | + | (append file-content `((tr | |
248 | + | (td ,old-line) | |
249 | + | (td ,new-line) | |
250 | + | (td ,origin) | |
251 | + | (td (@ (class ,(string-append class " diff-line"))) | |
252 | + | (pre ,line "\n")))))) | |
253 | + | (loop lines (+ old-line 1) (+ new-line 1)))))) | |
254 | + | 0)) | |
255 | + | (append content (cons file-header file-content)))) |
gitile/repo.scm
142 | 142 | (define (get-description repo) | |
143 | 143 | (let* ((config (repository-config repo)) | |
144 | 144 | (options (get-options config))) | |
145 | - | (assoc-ref options "gitweb.description"))) | |
145 | + | (or (assoc-ref options "gitweb.description") ""))) | |
146 | 146 | ||
147 | 147 | (define (get-commit repo hash) | |
148 | 148 | (let* ((oid (ref->oid repo hash)) |
guix.scm
34 | 34 | (method git-fetch) | |
35 | 35 | (uri (git-reference | |
36 | 36 | (url "https://gitlab.com/roptat/guile-git") | |
37 | - | (commit "8b752feec04138429a973080cc0170a376b73cda"))) | |
38 | - | (file-name (git-file-name "guile-git" "0.4.0.8b752fe")) | |
37 | + | (commit "c39ab944d8004d3ab751a9e27336469afec081eb"))) | |
38 | + | (file-name (git-file-name "guile-git" "0.4.0.c39ab94")) | |
39 | 39 | (sha256 | |
40 | 40 | (base32 | |
41 | - | "11k3h1spy2dlvc2lq9hpr0yypm9pav3y7d46dmwca31dlchj4jz8")))) | |
41 | + | "0hknsv9r7pjahmxkvd7zpz93saki5kymh88xs6pb4h9d0ssp4fmp")))) | |
42 | 42 | (native-inputs | |
43 | 43 | `(("autoconf" ,autoconf) | |
44 | 44 | ("automake" ,automake) |