self: Mark trivial "-modules" derivations as non-substitutable.
[jackhill/guix/guix.git] / guix / channels.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (guix channels)
22 #:use-module (git)
23 #:use-module (guix git)
24 #:use-module (guix records)
25 #:use-module (guix gexp)
26 #:use-module (guix modules)
27 #:use-module (guix discovery)
28 #:use-module (guix monads)
29 #:use-module (guix profiles)
30 #:use-module (guix derivations)
31 #:use-module (guix combinators)
32 #:use-module (guix diagnostics)
33 #:use-module (guix sets)
34 #:use-module (guix store)
35 #:use-module (guix i18n)
36 #:use-module ((guix utils)
37 #:select (source-properties->location
38 &error-location))
39 #:use-module (srfi srfi-1)
40 #:use-module (srfi srfi-2)
41 #:use-module (srfi srfi-9)
42 #:use-module (srfi srfi-11)
43 #:use-module (srfi srfi-26)
44 #:use-module (srfi srfi-34)
45 #:use-module (srfi srfi-35)
46 #:autoload (guix self) (whole-package make-config.scm)
47 #:autoload (guix inferior) (gexp->derivation-in-inferior) ;FIXME: circular dep
48 #:use-module (ice-9 match)
49 #:use-module (ice-9 vlist)
50 #:export (channel
51 channel?
52 channel-name
53 channel-url
54 channel-branch
55 channel-commit
56 channel-location
57
58 %default-channels
59 guix-channel?
60
61 channel-instance?
62 channel-instance-channel
63 channel-instance-commit
64 channel-instance-checkout
65
66 latest-channel-instances
67 checkout->channel-instance
68 latest-channel-derivation
69 channel-instances->manifest
70 %channel-profile-hooks
71 channel-instances->derivation
72
73 profile-channels
74
75 channel-news-entry?
76 channel-news-entry-commit
77 channel-news-entry-tag
78 channel-news-entry-title
79 channel-news-entry-body
80
81 channel-news-for-commit))
82
83 ;;; Commentary:
84 ;;;
85 ;;; This module implements "channels." A channel is usually a source of
86 ;;; package definitions. There's a special channel, the 'guix' channel, that
87 ;;; provides all of Guix, including its commands and its documentation.
88 ;;; User-defined channels are expected to typically provide a bunch of .scm
89 ;;; files meant to be added to the '%package-search-path'.
90 ;;;
91 ;;; This module provides tools to fetch and update channels from a Git
92 ;;; repository and to build them.
93 ;;;
94 ;;; Code:
95
96 (define-record-type* <channel> channel make-channel
97 channel?
98 (name channel-name)
99 (url channel-url)
100 (branch channel-branch (default "master"))
101 (commit channel-commit (default #f))
102 (location channel-location
103 (default (current-source-location)) (innate)))
104
105 (define %default-channels
106 ;; Default list of channels.
107 (list (channel
108 (name 'guix)
109 (branch "master")
110 (url "https://git.savannah.gnu.org/git/guix.git"))))
111
112 (define (guix-channel? channel)
113 "Return true if CHANNEL is the 'guix' channel."
114 (eq? 'guix (channel-name channel)))
115
116 (define-record-type <channel-instance>
117 (channel-instance channel commit checkout)
118 channel-instance?
119 (channel channel-instance-channel)
120 (commit channel-instance-commit)
121 (checkout channel-instance-checkout))
122
123 (define-record-type <channel-metadata>
124 (channel-metadata directory dependencies news-file)
125 channel-metadata?
126 (directory channel-metadata-directory) ;string with leading slash
127 (dependencies channel-metadata-dependencies) ;list of <channel>
128 (news-file channel-metadata-news-file)) ;string | #f
129
130 (define (channel-reference channel)
131 "Return the \"reference\" for CHANNEL, an sexp suitable for
132 'latest-repository-commit'."
133 (match (channel-commit channel)
134 (#f `(branch . ,(channel-branch channel)))
135 (commit `(commit . ,(channel-commit channel)))))
136
137 (define (read-channel-metadata port)
138 "Read from PORT channel metadata in the format expected for the
139 '.guix-channel' file. Return a <channel-metadata> record, or raise an error
140 if valid metadata could not be read from PORT."
141 (match (read port)
142 (('channel ('version 0) properties ...)
143 (let ((directory (and=> (assoc-ref properties 'directory) first))
144 (dependencies (or (assoc-ref properties 'dependencies) '()))
145 (news-file (and=> (assoc-ref properties 'news-file) first)))
146 (channel-metadata
147 (cond ((not directory) "/") ;directory
148 ((string-prefix? "/" directory) directory)
149 (else (string-append "/" directory)))
150 (map (lambda (item) ;dependencies
151 (let ((get (lambda* (key #:optional default)
152 (or (and=> (assoc-ref item key) first) default))))
153 (and-let* ((name (get 'name))
154 (url (get 'url))
155 (branch (get 'branch "master")))
156 (channel
157 (name name)
158 (branch branch)
159 (url url)
160 (commit (get 'commit))))))
161 dependencies)
162 news-file))) ;news-file
163 ((and ('channel ('version version) _ ...) sexp)
164 (raise (condition
165 (&message (message "unsupported '.guix-channel' version"))
166 (&error-location
167 (location (source-properties->location
168 (source-properties sexp)))))))
169 (sexp
170 (raise (condition
171 (&message (message "invalid '.guix-channel' file"))
172 (&error-location
173 (location (source-properties->location
174 (source-properties sexp)))))))))
175
176 (define (read-channel-metadata-from-source source)
177 "Return a channel-metadata record read from channel's SOURCE/.guix-channel
178 description file, or return the default channel-metadata record if that file
179 doesn't exist."
180 (catch 'system-error
181 (lambda ()
182 (call-with-input-file (string-append source "/.guix-channel")
183 read-channel-metadata))
184 (lambda args
185 (if (= ENOENT (system-error-errno args))
186 (channel-metadata "/" '() #f)
187 (apply throw args)))))
188
189 (define (channel-instance-metadata instance)
190 "Return a channel-metadata record read from the channel INSTANCE's
191 description file or its default value."
192 (read-channel-metadata-from-source (channel-instance-checkout instance)))
193
194 (define (channel-instance-dependencies instance)
195 "Return the list of channels that are declared as dependencies for the given
196 channel INSTANCE."
197 (channel-metadata-dependencies (channel-instance-metadata instance)))
198
199 (define* (latest-channel-instances store channels #:optional (previous-channels '()))
200 "Return a list of channel instances corresponding to the latest checkouts of
201 CHANNELS and the channels on which they depend. PREVIOUS-CHANNELS is a list
202 of previously processed channels."
203 ;; Only process channels that are unique, or that are more specific than a
204 ;; previous channel specification.
205 (define (ignore? channel others)
206 (member channel others
207 (lambda (a b)
208 (and (eq? (channel-name a) (channel-name b))
209 (or (channel-commit b)
210 (not (or (channel-commit a)
211 (channel-commit b))))))))
212
213 ;; Accumulate a list of instances. A list of processed channels is also
214 ;; accumulated to decide on duplicate channel specifications.
215 (define-values (resulting-channels instances)
216 (fold2 (lambda (channel previous-channels instances)
217 (if (ignore? channel previous-channels)
218 (values previous-channels instances)
219 (begin
220 (format (current-error-port)
221 (G_ "Updating channel '~a' from Git repository at '~a'...~%")
222 (channel-name channel)
223 (channel-url channel))
224 (let-values (((checkout commit)
225 (latest-repository-commit store (channel-url channel)
226 #:ref (channel-reference
227 channel))))
228 (let ((instance (channel-instance channel commit checkout)))
229 (let-values (((new-instances new-channels)
230 (latest-channel-instances
231 store
232 (channel-instance-dependencies instance)
233 previous-channels)))
234 (values (append (cons channel new-channels)
235 previous-channels)
236 (append (cons instance new-instances)
237 instances))))))))
238 previous-channels
239 '() ;instances
240 channels))
241
242 (let ((instance-name (compose channel-name channel-instance-channel)))
243 ;; Remove all earlier channel specifications if they are followed by a
244 ;; more specific one.
245 (values (delete-duplicates instances
246 (lambda (a b)
247 (eq? (instance-name a) (instance-name b))))
248 resulting-channels)))
249
250 (define* (checkout->channel-instance checkout
251 #:key commit
252 (url checkout) (name 'guix))
253 "Return a channel instance for CHECKOUT, which is assumed to be a checkout
254 of COMMIT at URL. Use NAME as the channel name."
255 (let* ((commit (or commit (make-string 40 #\0)))
256 (channel (channel (name name)
257 (commit commit)
258 (url url))))
259 (channel-instance channel commit checkout)))
260
261 (define %self-build-file
262 ;; The file containing code to build Guix. This serves the same purpose as
263 ;; a makefile, and, similarly, is intended to always keep this name.
264 "build-aux/build-self.scm")
265
266 (define %pull-version
267 ;; This is the version of the 'guix pull' protocol. It specifies what's
268 ;; expected from %SELF-BUILD-FILE. The initial version ("0") was when we'd
269 ;; place a set of compiled Guile modules in ~/.config/guix/latest.
270 1)
271
272 (define (standard-module-derivation name source core dependencies)
273 "Return a derivation that builds with CORE, a Guix instance, the Scheme
274 modules in SOURCE and that depend on DEPENDENCIES, a list of lowerable
275 objects. The assumption is that SOURCE contains package modules to be added
276 to '%package-module-path'."
277
278 (let* ((metadata (read-channel-metadata-from-source source))
279 (directory (channel-metadata-directory metadata)))
280
281 (define build
282 ;; This is code that we'll run in CORE, a Guix instance, with its own
283 ;; modules and so on. That way, we make sure these modules are built for
284 ;; the right Guile version, with the right dependencies, and that they get
285 ;; to see the right (gnu packages …) modules.
286 (with-extensions dependencies
287 #~(begin
288 (use-modules (guix build compile)
289 (guix build utils)
290 (srfi srfi-26))
291
292 (define go
293 (string-append #$output "/lib/guile/" (effective-version)
294 "/site-ccache"))
295 (define scm
296 (string-append #$output "/share/guile/site/"
297 (effective-version)))
298
299 (let* ((subdir #$directory)
300 (source (string-append #$source subdir)))
301 (compile-files source go (find-files source "\\.scm$"))
302 (mkdir-p (dirname scm))
303 (symlink (string-append #$source subdir) scm))
304
305 scm)))
306
307 (gexp->derivation-in-inferior name build core)))
308
309 (define* (build-from-source name source
310 #:key core verbose? commit
311 (dependencies '()))
312 "Return a derivation to build Guix from SOURCE, using the self-build script
313 contained therein; use COMMIT as the version string. When CORE is true, build
314 package modules under SOURCE using CORE, an instance of Guix."
315 ;; Running the self-build script makes it easier to update the build
316 ;; procedure: the self-build script of the Guix-to-be-installed contains the
317 ;; right dependencies, build procedure, etc., which the Guix-in-use may not
318 ;; be know.
319 (define script
320 (string-append source "/" %self-build-file))
321
322 (if (file-exists? script)
323 (let ((build (save-module-excursion
324 (lambda ()
325 ;; Disable deprecation warnings; it's OK for SCRIPT to
326 ;; use deprecated APIs and the user doesn't have to know
327 ;; about it.
328 (parameterize ((guix-warning-port
329 (%make-void-port "w")))
330 (primitive-load script))))))
331 ;; BUILD must be a monadic procedure of at least one argument: the
332 ;; source tree.
333 ;;
334 ;; Note: BUILD can return #f if it does not support %PULL-VERSION. In
335 ;; the future we'll fall back to a previous version of the protocol
336 ;; when that happens.
337 (build source #:verbose? verbose? #:version commit
338 #:pull-version %pull-version))
339
340 ;; Build a set of modules that extend Guix using the standard method.
341 (standard-module-derivation name source core dependencies)))
342
343 (define* (build-channel-instance instance
344 #:optional core (dependencies '()))
345 "Return, as a monadic value, the derivation for INSTANCE, a channel
346 instance. DEPENDENCIES is a list of extensions providing Guile modules that
347 INSTANCE depends on."
348 (build-from-source (symbol->string
349 (channel-name (channel-instance-channel instance)))
350 (channel-instance-checkout instance)
351 #:commit (channel-instance-commit instance)
352 #:core core
353 #:dependencies dependencies))
354
355 (define (resolve-dependencies instances)
356 "Return a procedure that, given one of the elements of INSTANCES, returns
357 list of instances it depends on."
358 (define channel-instance-name
359 (compose channel-name channel-instance-channel))
360
361 (define table ;map a name to an instance
362 (fold (lambda (instance table)
363 (vhash-consq (channel-instance-name instance)
364 instance table))
365 vlist-null
366 instances))
367
368 (define edges
369 (fold (lambda (instance edges)
370 (fold (lambda (channel edges)
371 (let ((name (channel-name channel)))
372 (match (vhash-assq name table)
373 ((_ . target)
374 (vhash-consq instance target edges)))))
375 edges
376 (channel-instance-dependencies instance)))
377 vlist-null
378 instances))
379
380 (lambda (instance)
381 (vhash-foldq* cons '() instance edges)))
382
383 (define (channel-instance-derivations instances)
384 "Return the list of derivations to build INSTANCES, in the same order as
385 INSTANCES."
386 (define core-instance
387 ;; The 'guix' channel is treated specially: it's an implicit dependency of
388 ;; all the other channels.
389 (find (lambda (instance)
390 (guix-channel? (channel-instance-channel instance)))
391 instances))
392
393 (define edges
394 (resolve-dependencies instances))
395
396 (define (instance->derivation instance)
397 (mlet %store-monad ((system (current-system)))
398 (mcached (if (eq? instance core-instance)
399 (build-channel-instance instance)
400 (mlet %store-monad ((core (instance->derivation core-instance))
401 (deps (mapm %store-monad instance->derivation
402 (edges instance))))
403 (build-channel-instance instance core deps)))
404 instance
405 system)))
406
407 (unless core-instance
408 (let ((loc (and=> (any (compose channel-location channel-instance-channel)
409 instances)
410 source-properties->location)))
411 (raise (apply make-compound-condition
412 (condition
413 (&message (message "'guix' channel is lacking")))
414 (if loc
415 (list (condition (&error-location (location loc))))
416 '())))))
417
418 (mapm %store-monad instance->derivation instances))
419
420 (define (whole-package-for-legacy name modules)
421 "Return a full-blown Guix package for MODULES, a derivation that builds Guix
422 modules in the old ~/.config/guix/latest style."
423 (define packages
424 (resolve-interface '(gnu packages guile)))
425
426 (define modules+compiled
427 ;; Since MODULES contains both .scm and .go files at its root, re-bundle
428 ;; it so that it has share/guile/site and lib/guile, which is what
429 ;; 'whole-package' expects.
430 (computed-file (derivation-name modules)
431 (with-imported-modules '((guix build utils))
432 #~(begin
433 (use-modules (guix build utils))
434
435 (define version
436 (effective-version))
437 (define share
438 (string-append #$output "/share/guile/site"))
439 (define lib
440 (string-append #$output "/lib/guile/" version))
441
442 (mkdir-p share) (mkdir-p lib)
443 (symlink #$modules (string-append share "/" version))
444 (symlink #$modules (string-append lib "/site-ccache"))))))
445
446 (letrec-syntax ((list (syntax-rules (->)
447 ((_)
448 '())
449 ((_ (module -> variable) rest ...)
450 (cons (module-ref (resolve-interface
451 '(gnu packages module))
452 'variable)
453 (list rest ...)))
454 ((_ variable rest ...)
455 (cons (module-ref packages 'variable)
456 (list rest ...))))))
457 (whole-package name modules+compiled
458
459 ;; In the "old style", %SELF-BUILD-FILE would simply return a
460 ;; derivation that builds modules. We have to infer what the
461 ;; dependencies of these modules were.
462 (list guile-json guile-git guile-bytestructures
463 (ssh -> guile-ssh) (tls -> gnutls)))))
464
465 (define (old-style-guix? drv)
466 "Return true if DRV corresponds to a ~/.config/guix/latest style of
467 derivation."
468 ;; Here we rely on a gross historical fact: that derivations produced by the
469 ;; "old style" (before commit 8a0d9bc8a3f153159d9e239a151c0fa98f1e12d8,
470 ;; dated May 30, 2018) did not depend on "guix-command.drv".
471 (not (find (lambda (input)
472 (string=? "guix-command"
473 (derivation-name
474 (derivation-input-derivation input))))
475 (derivation-inputs drv))))
476
477 (define (channel-instances->manifest instances)
478 "Return a profile manifest with entries for all of INSTANCES, a list of
479 channel instances."
480 (define (instance->entry instance drv)
481 (let ((commit (channel-instance-commit instance))
482 (channel (channel-instance-channel instance)))
483 (manifest-entry
484 (name (symbol->string (channel-name channel)))
485 (version (string-take commit 7))
486 (item (if (guix-channel? channel)
487 (if (old-style-guix? drv)
488 (whole-package-for-legacy (string-append name "-" version)
489 drv)
490 drv)
491 drv))
492 (properties
493 `((source (repository
494 (version 0)
495 (url ,(channel-url channel))
496 (branch ,(channel-branch channel))
497 (commit ,commit))))))))
498
499 (mlet* %store-monad ((derivations (channel-instance-derivations instances))
500 (entries -> (map instance->entry instances derivations)))
501 (return (manifest entries))))
502
503 (define (package-cache-file manifest)
504 "Build a package cache file for the instance in MANIFEST. This is meant to
505 be used as a profile hook."
506 (mlet %store-monad ((profile (profile-derivation manifest
507 #:hooks '())))
508
509 (define build
510 #~(begin
511 (use-modules (gnu packages))
512
513 (if (defined? 'generate-package-cache)
514 (begin
515 ;; Delegate package cache generation to the inferior.
516 (format (current-error-port)
517 "Generating package cache for '~a'...~%"
518 #$profile)
519 (generate-package-cache #$output))
520 (mkdir #$output))))
521
522 (gexp->derivation-in-inferior "guix-package-cache" build
523 profile
524
525 ;; If the Guix in PROFILE is too old and
526 ;; lacks 'guix repl', don't build the cache
527 ;; instead of failing.
528 #:silent-failure? #t
529
530 #:properties '((type . profile-hook)
531 (hook . package-cache))
532 #:local-build? #t)))
533
534 (define %channel-profile-hooks
535 ;; The default channel profile hooks.
536 (cons package-cache-file %default-profile-hooks))
537
538 (define (channel-instances->derivation instances)
539 "Return the derivation of the profile containing INSTANCES, a list of
540 channel instances."
541 (mlet %store-monad ((manifest (channel-instances->manifest instances)))
542 (profile-derivation manifest
543 #:hooks %channel-profile-hooks)))
544
545 (define latest-channel-instances*
546 (store-lift latest-channel-instances))
547
548 (define* (latest-channel-derivation #:optional (channels %default-channels))
549 "Return as a monadic value the derivation that builds the profile for the
550 latest instances of CHANNELS."
551 (mlet %store-monad ((instances (latest-channel-instances* channels)))
552 (channel-instances->derivation instances)))
553
554 (define (profile-channels profile)
555 "Return the list of channels corresponding to entries in PROFILE. If
556 PROFILE is not a profile created by 'guix pull', return the empty list."
557 (filter-map (lambda (entry)
558 (match (assq 'source (manifest-entry-properties entry))
559 (('source ('repository ('version 0)
560 ('url url)
561 ('branch branch)
562 ('commit commit)
563 _ ...))
564 (channel (name (string->symbol
565 (manifest-entry-name entry)))
566 (url url)
567 (commit commit)))
568
569 ;; No channel information for this manifest entry.
570 ;; XXX: Pre-0.15.0 Guix did not provide that information,
571 ;; but there's not much we can do in that case.
572 (_ #f)))
573
574 ;; Show most recently installed packages last.
575 (reverse
576 (manifest-entries (profile-manifest profile)))))
577
578 \f
579 ;;;
580 ;;; News.
581 ;;;
582
583 ;; Channel news.
584 (define-record-type <channel-news>
585 (channel-news entries)
586 channel-news?
587 (entries channel-news-entries)) ;list of <channel-news-entry>
588
589 ;; News entry, associated with a specific commit of the channel.
590 (define-record-type <channel-news-entry>
591 (channel-news-entry commit tag title body)
592 channel-news-entry?
593 (commit channel-news-entry-commit) ;hex string | #f
594 (tag channel-news-entry-tag) ;#f | string
595 (title channel-news-entry-title) ;list of language tag/string pairs
596 (body channel-news-entry-body)) ;list of language tag/string pairs
597
598 (define (sexp->channel-news-entry entry)
599 "Return the <channel-news-entry> record corresponding to ENTRY, an sexp."
600 (define (pair language message)
601 (cons (symbol->string language) message))
602
603 (match entry
604 (('entry ((and (or 'commit 'tag) type) commit-or-tag)
605 ('title ((? symbol? title-tags) (? string? titles)) ...)
606 ('body ((? symbol? body-tags) (? string? bodies)) ...)
607 _ ...)
608 (channel-news-entry (and (eq? type 'commit) commit-or-tag)
609 (and (eq? type 'tag) commit-or-tag)
610 (map pair title-tags titles)
611 (map pair body-tags bodies)))
612 (_
613 (raise (condition
614 (&message (message "invalid channel news entry"))
615 (&error-location
616 (location (source-properties->location
617 (source-properties entry)))))))))
618
619 (define (read-channel-news port)
620 "Read a channel news feed from PORT and return it as a <channel-news>
621 record."
622 (match (false-if-exception (read port))
623 (('channel-news ('version 0) entries ...)
624 (channel-news (map sexp->channel-news-entry entries)))
625 (('channel-news ('version version) _ ...)
626 ;; This is an unsupported version from the future. There's nothing wrong
627 ;; with that (the user may simply need to upgrade the 'guix' channel to
628 ;; be able to read it), so silently ignore it.
629 (channel-news '()))
630 (#f
631 (raise (condition
632 (&message (message "syntactically invalid channel news file")))))
633 (sexp
634 (raise (condition
635 (&message (message "invalid channel news file"))
636 (&error-location
637 (location (source-properties->location
638 (source-properties sexp)))))))))
639
640 (define (resolve-channel-news-entry-tag repository entry)
641 "If ENTRY has its 'commit' field set, return ENTRY. Otherwise, lookup
642 ENTRY's 'tag' in REPOSITORY and return ENTRY with its 'commit' field set to
643 the field its 'tag' refers to. A 'git-error' exception is raised if the tag
644 cannot be found."
645 (if (channel-news-entry-commit entry)
646 entry
647 (let* ((tag (channel-news-entry-tag entry))
648 (reference (string-append "refs/tags/" tag))
649 (oid (reference-name->oid repository reference)))
650 (channel-news-entry (oid->string oid) tag
651 (channel-news-entry-title entry)
652 (channel-news-entry-body entry)))))
653
654 (define* (channel-news-for-commit channel new #:optional old)
655 "Return a list of <channel-news-entry> for CHANNEL between commits OLD and
656 NEW. When OLD is omitted or is #f, return all the news entries of CHANNEL."
657 (catch 'git-error
658 (lambda ()
659 (let* ((checkout (update-cached-checkout (channel-url channel)
660 #:ref `(commit . ,new)))
661 (metadata (read-channel-metadata-from-source checkout))
662 (news-file (channel-metadata-news-file metadata))
663 (news-file (and news-file
664 (string-append checkout "/" news-file))))
665 (if (and news-file (file-exists? news-file))
666 (with-repository checkout repository
667 (let* ((news (call-with-input-file news-file
668 read-channel-news))
669 (entries (map (lambda (entry)
670 (resolve-channel-news-entry-tag repository
671 entry))
672 (channel-news-entries news))))
673 (if old
674 (let* ((new (commit-lookup repository (string->oid new)))
675 (old (commit-lookup repository (string->oid old)))
676 (commits (list->set
677 (map (compose oid->string commit-id)
678 (commit-difference new old)))))
679 (filter (lambda (entry)
680 (set-contains? commits
681 (channel-news-entry-commit entry)))
682 entries))
683 entries)))
684 '())))
685 (lambda (key error . rest)
686 ;; If commit NEW or commit OLD cannot be found, then something must be
687 ;; wrong (for example, the history of CHANNEL was rewritten and these
688 ;; commits no longer exist upstream), so quietly return the empty list.
689 (if (= GIT_ENOTFOUND (git-error-code error))
690 '()
691 (apply throw key error rest)))))