mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-19 22:16:32 +01:00
import: github: Improve readability.
* guix/import/github.scm (latest-released-version)[release->version]: Separate out release->version as a new function.
This commit is contained in:
parent
0f9bbd32c1
commit
c558772b0f
1 changed files with 27 additions and 26 deletions
|
@ -174,17 +174,7 @@ (define (latest-released-version url package-name)
|
|||
(define (pre-release? x)
|
||||
(hash-ref x "prerelease"))
|
||||
|
||||
(let* ((json (fetch-releases-or-tags url)))
|
||||
(if (eq? json #f)
|
||||
(if (%github-token)
|
||||
(error "Error downloading release information through the GitHub
|
||||
API when using a GitHub token")
|
||||
(error "Error downloading release information through the GitHub
|
||||
API. This may be fixed by using an access token and setting the environment
|
||||
variable GUIX_GITHUB_TOKEN, for instance one procured from
|
||||
https://github.com/settings/tokens"))
|
||||
(any
|
||||
(lambda (release)
|
||||
(define (release->version release)
|
||||
(let ((tag (or (hash-ref release "tag_name") ;a "release"
|
||||
(hash-ref release "name"))) ;a tag
|
||||
(name-length (string-length package-name)))
|
||||
|
@ -206,6 +196,17 @@ (define (pre-release? x)
|
|||
(string-ref tag 0)))
|
||||
tag)
|
||||
(else #f))))
|
||||
|
||||
(let* ((json (fetch-releases-or-tags url)))
|
||||
(if (eq? json #f)
|
||||
(if (%github-token)
|
||||
(error "Error downloading release information through the GitHub
|
||||
API when using a GitHub token")
|
||||
(error "Error downloading release information through the GitHub
|
||||
API. This may be fixed by using an access token and setting the environment
|
||||
variable GUIX_GITHUB_TOKEN, for instance one procured from
|
||||
https://github.com/settings/tokens"))
|
||||
(any release->version
|
||||
(match (remove pre-release? json)
|
||||
(() json) ; keep everything
|
||||
(releases releases))))))
|
||||
|
|
Loading…
Reference in a new issue