chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] What's the current version of eggs?


From: Alejandro Forero Cuervo
Subject: Re: [Chicken-users] What's the current version of eggs?
Date: Tue, 26 Feb 2008 07:18:56 -0800
User-agent: Mutt/1.5.13 (2006-08-11)

> For tagged eggs, the version number is the name of the most
> recently-added tag (correct)?

No.  The version number is the greatest string sorting them as a human
would compare version numbers (eg. 1.12 is greater than 1.9.2, and the
date in which they were added is not relevant).  There is an
exception: if the Subversion property "latest" is set in the tags/
directory, it takes precedence.

The specific logic (which I implemented a long time ago) is this:

(define (version-string->numbers string)
  (map string->number (string-split string ".")))

(define (version-numbers> a b)
  (and (not (null? a))
       (or (null? b)
           (> (car a) (car b))
           (and (= (car a) (car b))
                (version-numbers> (cdr a) (cdr b))))))

(define (pick-latest-version tags-dir)
  (fold
    (lambda (a pick)
      (let ((a-nums (version-string->numbers a)))
        (if (and (every number? a-nums) ; sanity check
                 (version-numbers>
                   a-nums
                   (version-string->numbers pick)))
          a
          pick)))
    ""
    (directory tags-dir)))

Now that I think about it, perhaps this can be optimized using the
orders egg! ;-)

Thanks! :-)

Alejo.
http://azul.freaks-unidos.net/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]