import: github: Filter out tags that don't look like version numbers.
* guix/import/github.scm (latest-released-version): Filter out RELEASE if it doesn't start with digit.
This commit is contained in:
		
							parent
							
								
									64bcc76c00
								
							
						
					
					
						commit
						bab4dc58f7
					
				
					 1 changed files with 22 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -172,7 +172,7 @@ API when using a GitHub token")
 | 
			
		|||
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"))
 | 
			
		||||
        (let ((proper-releases
 | 
			
		||||
        (let loop ((releases
 | 
			
		||||
                    (filter
 | 
			
		||||
                     (lambda (x)
 | 
			
		||||
                       ;; example pre-release:
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ https://github.com/settings/tokens"))
 | 
			
		|||
                       ;; https://github.com/powertab/powertabeditor/releases
 | 
			
		||||
                       (not (hash-ref x "prerelease")))
 | 
			
		||||
                     json)))
 | 
			
		||||
          (match proper-releases
 | 
			
		||||
          (match releases
 | 
			
		||||
            (()                                   ;empty release list
 | 
			
		||||
             #f)
 | 
			
		||||
            ((release . rest)                     ;one or more releases
 | 
			
		||||
| 
						 | 
				
			
			@ -196,8 +196,16 @@ https://github.com/settings/tokens"))
 | 
			
		|||
                   (substring tag (+ name-length 1))
 | 
			
		||||
                   ;; some tags start with a "v" e.g. "v0.25.0"
 | 
			
		||||
                   ;; where some are just the version number
 | 
			
		||||
                   (if (eq? (string-ref tag 0) #\v)
 | 
			
		||||
                       (substring tag 1) tag)))))))))
 | 
			
		||||
                   (if (string-prefix? "v" tag)
 | 
			
		||||
                       (substring tag 1)
 | 
			
		||||
 | 
			
		||||
                       ;; Finally, reject tags that don't start with a digit:
 | 
			
		||||
                       ;; they may not represent a release.
 | 
			
		||||
                       (if (and (not (string-null? tag))
 | 
			
		||||
                                (char-set-contains? char-set:digit
 | 
			
		||||
                                                    (string-ref tag 0)))
 | 
			
		||||
                           tag
 | 
			
		||||
                           (loop rest)))))))))))
 | 
			
		||||
 | 
			
		||||
(define (latest-release pkg)
 | 
			
		||||
  "Return an <upstream-source> for the latest release of PKG."
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue