[DRE-maint] Bug#829362: ruby-ronn: please make the output reproducible
Antonio Terceiro
terceiro at debian.org
Sun Sep 4 23:30:39 UTC 2016
On Sun, Sep 04, 2016 at 10:19:35PM +0100, Chris Lamb wrote:
> > yeah that was a typo, but again, ronn does not do locales (at all)
>
> Looking into this, it appear's that ruby's strftime is locale independent,
> rather than something ronn-specific. This the opposite behaviour to every
> other strftime that I've come across, hence the confusion.
Last time I checked strftime in any language will only format according
to the locale defined by environment variables if and only if the
program calling strftime has initialized the locale system with
setlocale().
> However, you are still missing:
>
> - date.strftime
> + date.utc.strftime
one of the things that was making the test crash was this. in Ruby, `Date`
objects do not have a `utc` method.
> … for when building close to month changes with respect to TZ.
let's see
> --- a/lib/ronn/document.rb
> +++ b/lib/ronn/document.rb
> @@ -165,6 +165,7 @@ module Ronn
> # the current time.
> def date
> return @date if @date
if the date has been passed explicitly in the command line (with `ron --date
...`), it will be a fixed date and thus will not vary according to $TZ.
ronn parses the date with
options['date'] &&= Date.strptime(options['date'], '%Y-%m-%d')
so let's do that
$ TZ=UTC ruby -rdate -e 'puts Date.strptime("2016-10-01", "%Y-%m-%d")'
2016-10-01
$ TZ=Asia/Tokyo ruby -rdate -e 'puts Date.strptime("2016-10-01", "%Y-%m-%d")'
2016-10-01
Also, Date objects in Ruby do not store either hours or timezones. Only Time
objcts do that.
> + return Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime if ENV['SOURCE_DATE_EPOCH']
otherwise, if SOURCE_DATE_EPOCH is passed, the date is _already_ in UTC (`utc`
and `gmtime` are synonyms in the ruby date class).
> return File.mtime(path) if File.exist?(path)
> Time.now
> end
I believe the patch as it currently is solves any reproducibility issues. if
you can find a concrete and reproducible case where it does not, please report
a new bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-ruby-extras-maintainers/attachments/20160904/9abe7c1c/attachment-0001.sig>
More information about the Pkg-ruby-extras-maintainers
mailing list