civodul pushed a commit to branch master
in repository guix.
commit 63ed618e337a466772aadd6ef3b919b7f04b666d
Author: Ludovic Courtès <[email protected]>
AuthorDate: Mon Sep 6 14:03:28 2021 +0200
swh: <revisions> accept null 'date' fields.
* guix/swh.scm (maybe-null): New procedure.
(<revision>)[date]: Use it.
---
guix/swh.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/guix/swh.scm b/guix/swh.scm
index 7b14a70..4d0a647 100644
--- a/guix/swh.scm
+++ b/guix/swh.scm
@@ -186,6 +186,12 @@ Software Heritage."
(ref 10))))))
str)) ;oops!
+(define (maybe-null proc)
+ (match-lambda
+ ((? null?) #f)
+ ('null #f)
+ (obj (proc obj))))
+
(define string*
;; Converts "string or #nil" coming from JSON to "string or #f".
(match-lambda
@@ -319,10 +325,13 @@ FALSE-IF-404? is true, return #f upon 404 responses."
(target-url release-target-url "target_url"))
;;
<https://archive.softwareheritage.org/api/1/revision/359fdda40f754bbf1b5dc261e7427b75463b59be/>
+;; Note: Some revisions, such as those for "nixguix" origins (e.g.,
+;;
<https://archive.softwareheritage.org/api/1/revision/b8dbc65475bbedde8e015d4730ade8864c38fad3/>),
+;; have their 'date' field set to null.
(define-json-mapping <revision> make-revision revision?
json->revision
(id revision-id)
- (date revision-date "date" string->date*)
+ (date revision-date "date" (maybe-null string->date*))
(directory revision-directory)
(directory-url revision-directory-url "directory_url"))