Finally implement commit page.

Julien LepillerSat Mar 06 21:52:49+0100 2021

836b4c2

Finally implement commit page.

gitile/handler.scm

9898
          (show (style (project-commits project-name (get-repo project-name) ref)
9999
		       project-name ref)))
100100
         ((project-name "commit" ref)
101-
          (show (style not-yet-page project-name ref)))
101+
          (show (style (project-commit project-name (get-repo project-name) ref)
102+
                       project-name ref)))
102103
         ((project-name "tags")
103104
          (show (style (project-tags project-name (get-repo project-name))
104105
		       project-name "-")))

gitile/pages.scm

3131
            project-files
3232
            project-index
3333
            project-commits
34+
            project-commit
3435
	    project-tags))
3536
3637
(define not-yet-page

127128
         (commit (last-commit repo ref)))
128129
    (commit-infobox repository-name commit)))
129130
130-
(define* (commit-infobox repository-name commit #:key (open? #f))
131+
(define* (commit-infobox repository-name commit #:key (open? #f) (detailed? #f))
131132
  `(div (@ (class "commit-info"))
132133
     (p (img (@ (src ,(author-image (commit-author commit))))))
133134
     (div (@ (class "commit"))

191192
    (if (null? tags)
192193
	`((p "This project has no tags yet."))
193194
	`((p "There are tags, but we don't know how to show them yet.")))))
195+
196+
(define (project-commit repository-name repo ref)
197+
  (let* ((commit (get-commit repo ref))
198+
         (parent (commit-parent commit)))
199+
    `(div
200+
      ,(commit-infobox repository-name commit #:open? #t)
201+
      (p (@ (class "commit-summary")) ,(commit-summary commit))
202+
      (pre (@ (class "diff"))
203+
        ,(diff->string (diff-tree-to-tree repo (commit-tree parent)
204+
                                          (commit-tree commit)))))))

gitile/repo.scm

2626
            get-files
2727
            get-file-content
2828
            get-commits
29+
            get-commit
2930
            get-description
3031
            last-commit
3132

142143
  (let* ((config (repository-config repo))
143144
         (options (get-options config)))
144145
    (assoc-ref options "gitweb.description")))
146+
147+
(define (get-commit repo hash)
148+
  (let* ((oid (ref->oid repo hash))
149+
         (commit (commit-lookup repo oid)))
150+
    commit))

guix.scm

1818
(use-modules (guix packages)
1919
             (guix licenses)
2020
             (guix build-system gnu)
21+
             (guix git-download)
2122
             (gnu packages autotools)
2223
             (gnu packages gnupg)
2324
             (gnu packages guile)
2425
             (gnu packages guile-xyz)
2526
             (gnu packages pkg-config)
27+
             (gnu packages texinfo)
2628
             (gnu packages tls))
2729
30+
(define my-guile-git
31+
  (package
32+
    (inherit guile-git)
33+
    (source (origin
34+
              (method git-fetch)
35+
              (uri (git-reference
36+
                     (url "https://gitlab.com/roptat/guile-git")
37+
                     (commit "8b752feec04138429a973080cc0170a376b73cda")))
38+
              (file-name (git-file-name "guile-git" "0.4.0.8b752fe"))
39+
              (sha256
40+
               (base32
41+
                "11k3h1spy2dlvc2lq9hpr0yypm9pav3y7d46dmwca31dlchj4jz8"))))
42+
    (native-inputs
43+
     `(("autoconf" ,autoconf)
44+
       ("automake" ,automake)
45+
       ("texinfo" ,texinfo)
46+
       ,@(package-native-inputs guile-git)))))
47+
2848
(package
2949
  (name "gitile")
3050
  (version "0.1")
3151
  (source #f)
3252
  (build-system gnu-build-system)
33-
  (inputs
34-
   `(("guile-git" ,guile-git)
53+
  (propagated-inputs
54+
   `(("guile-git" ,my-guile-git)
3555
     ("guile-gcrypt" ,guile-gcrypt)
3656
     ("gnutls" ,gnutls)
3757
     ("guile-fibers" ,guile-fibers)))