Display tags.
gitile/pages.scm
32 | 32 | project-index | |
33 | 33 | project-commits | |
34 | 34 | project-commit | |
35 | - | project-tags)) | |
35 | + | project-tags)) | |
36 | 36 | ||
37 | 37 | (define not-yet-page | |
38 | 38 | `((p "Not yet available, sorry :/"))) | |
… | |||
118 | 118 | (string->utf8 (signature-email author)) | |
119 | 119 | (hash-algorithm sha1))))) | |
120 | 120 | ||
121 | - | (define (commit->date-string commit) | |
121 | + | (define (time->date-string time) | |
122 | 122 | (date->string | |
123 | 123 | (time-utc->date | |
124 | - | (make-time time-utc 0 (commit-time commit))))) | |
124 | + | (make-time time-utc 0 time)))) | |
125 | 125 | ||
126 | 126 | (define (last-commit-infobox repository-name repo ref) | |
127 | 127 | (let* ((ref (if (equal? ref "-") #f ref)) | |
… | |||
139 | 139 | (p (span (@ (class "author")) | |
140 | 140 | ,(signature-name (commit-author commit))) | |
141 | 141 | (span (@ (class "date")) | |
142 | - | ,(commit->date-string commit)))) | |
142 | + | ,(time->date-string (commit-time commit))))) | |
143 | 143 | (div (@ (class "commit-id")) | |
144 | 144 | (p (@ (class "short-id")) | |
145 | 145 | ,(string-take (oid->string (commit-id commit)) 7)) | |
… | |||
150 | 150 | `(a (@ (href "/" ,repository-name "/tree/" | |
151 | 151 | ,(oid->string (commit-id commit)))) | |
152 | 152 | (img (@ (src "/images/go.svg")))) | |
153 | - | '())))) | |
153 | + | '())))) | |
154 | 154 | ||
155 | 155 | (define (project-commits repository-name repo ref) | |
156 | 156 | (let* ((commits (get-commits repo ref)) | |
… | |||
189 | 189 | ||
190 | 190 | (define (project-tags repository-name repo) | |
191 | 191 | (let ((tags (get-tags repo))) | |
192 | + | (pk 'tags tags) | |
192 | 193 | (if (null? tags) | |
193 | - | `((p "This project has no tags yet.")) | |
194 | - | `((p "There are tags, but we don't know how to show them yet."))))) | |
194 | + | `((p "This project has no tags yet.")) | |
195 | + | (map (lambda (tag) (tag-box repository-name tag)) tags)))) | |
196 | + | ||
197 | + | (define (tag-box repository-name tag) | |
198 | + | (pk tag) | |
199 | + | (match tag | |
200 | + | (($ <mytag> name message target time) | |
201 | + | `(div (@ (class "tag-box")) | |
202 | + | (div (@ (class "tag")) | |
203 | + | (p (a (@ (href ,repository-name "/tree/" ,target)) ,name)) | |
204 | + | (p (span (@ (class "date")) | |
205 | + | ,(time->date-string time)))) | |
206 | + | (p ,message))))) | |
195 | 207 | ||
196 | 208 | (define (project-commit repository-name repo ref) | |
197 | 209 | (let* ((commit (get-commit repo ref)) |
gitile/repo.scm
34 | 34 | make-file | |
35 | 35 | file? | |
36 | 36 | file-name | |
37 | - | file-type)) | |
37 | + | file-type | |
38 | + | ||
39 | + | <mytag> | |
40 | + | make-mytag | |
41 | + | mytag-name | |
42 | + | mytag-message | |
43 | + | mytag-target)) | |
38 | 44 | ||
39 | 45 | (define tree-entry-type | |
40 | 46 | (let ((proc (libgit2->procedure int "git_tree_entry_type" '(*)))) | |
41 | 47 | (lambda (entry) | |
42 | 48 | (proc (tree-entry->pointer entry))))) | |
43 | 49 | ||
50 | + | (define tag-foreach | |
51 | + | (let ((proc (libgit2->procedure* "git_tag_foreach" | |
52 | + | `(* * *)))) | |
53 | + | (lambda (repository callback) | |
54 | + | (let ((callback* (procedure->pointer int | |
55 | + | (lambda (name oid _) | |
56 | + | (callback | |
57 | + | (pointer->string name) | |
58 | + | (pointer->oid oid))) | |
59 | + | '(* * *)))) | |
60 | + | (proc (repository->pointer repository) callback* %null-pointer))))) | |
61 | + | ||
44 | 62 | (define (get-branches repo) | |
45 | 63 | (map (lambda (ref) (cons (reference-shorthand ref) (reference-name ref))) | |
46 | 64 | (filter reference-branch? (reference-fold cons '() repo)))) | |
47 | 65 | ||
66 | + | (define-record-type <mytag> | |
67 | + | (make-mytag name message target date) | |
68 | + | mytag? | |
69 | + | (name mytag-name) | |
70 | + | (message mytag-message) | |
71 | + | (target mytag-target) | |
72 | + | (date mytag-date)) | |
73 | + | ||
48 | 74 | (define (get-tags repo) | |
49 | - | (map (lambda (ref) (cons (reference-shorthand ref) (reference-name ref))) | |
50 | - | (filter reference-tag? (reference-fold cons '() repo)))) | |
75 | + | (let ((tags '())) | |
76 | + | (tag-foreach | |
77 | + | repo | |
78 | + | (lambda (name oid) | |
79 | + | (let* ((tag (false-if-exception (tag-lookup repo oid))) | |
80 | + | (oid (if tag (tag-target-id tag) oid)) | |
81 | + | (commit (commit-lookup repo oid)) | |
82 | + | (date (commit-time commit))) | |
83 | + | (set! tags | |
84 | + | (cons | |
85 | + | (make-mytag | |
86 | + | (cond | |
87 | + | (tag (tag-name tag)) | |
88 | + | ((string-prefix? "refs/tags/" name) | |
89 | + | (substring name (string-length "refs/tags/"))) | |
90 | + | (else name)) | |
91 | + | (if tag (tag-message tag) "") | |
92 | + | (oid->string oid) | |
93 | + | date) | |
94 | + | tags))) | |
95 | + | 0)) | |
96 | + | (sort tags (lambda (t1 t2) (> (mytag-date t1) (mytag-date t2)))))) | |
51 | 97 | ||
52 | 98 | (define (search-reference repo name) | |
53 | 99 | (reference-fold (lambda (ref acc) |