diff mbox series

[bug#61420,01/31] import: hackage: Allow version at the beginning of cabal file.

Message ID 20230211100825.47971-1-lars@6xq.net
State New
Headers show
Series Haskell upgrade to Stackage 20.5 | expand

Commit Message

Lars-Dominik Braun Feb. 11, 2023, 10:07 a.m. UTC
Fix a corner case, uncovered by the hedgehog package, which has the
version field at the beginning of its cabal file. This causes a pattern
match failure.

* guix/import/hackage.scm (latest-release): Match version at beginning
of expression too.
---
 guix/import/hackage.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 7bc2908405..e915aac58d 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -378,7 +378,10 @@  (define* (latest-release package #:key (version #f))
                "warning: failed to parse ~a~%"
                (hackage-cabal-url hackage-name))
        #f)
-      ((_ *** ("version" (version)))
+      ;; Cabal files have no particular order and while usually the version
+      ;; as somewhere in the middle it can also be at the beginning,
+      ;; requiring two pattern.
+      ((or (_ *** ("version" (version))) (("version" (version)) _ ...))
        (let ((url (hackage-uri hackage-name version)))
          (upstream-source
           (package (package-name package))