From: intrigeri Date: Mon, 27 Jun 2016 13:23:53 +0000 Subject: Honour SOURCE_DATE_EPOCH for embedded timestamp in generated documentation. When the environment variable SOURCE_DATE_EPOCH is set, use it instead of the current time for the embedded build timestamp. The specification of SOURCE_DATE_EPOCH is available here: https://reproducible-builds.org/specs/source-date-epoch/ In the case it is not defined, fall back to current time. --- lib/Command/V1.pm | 2 +- lib/Command/View/DocMethods.pm | 2 +- lib/UR/Context.pm | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) --- a/lib/Command/V1.pm +++ b/lib/Command/V1.pm @@ -598,7 +598,7 @@ sub doc_sections { my $command_name = $self->command_name; my $version = do { no strict; ${ $self->class . '::VERSION' } }; my $help_brief = $self->help_brief; - my $datetime = $self->__context__->now; + my $datetime = $self->__context__->build_time; my $sub_commands = $self->help_sub_commands(brief => 1) if $self->is_sub_command_delegator; my ($date,$time) = split(' ',$datetime); --- a/lib/Command/View/DocMethods.pm +++ b/lib/Command/View/DocMethods.pm @@ -168,7 +168,7 @@ sub doc_sections { my $version = do { no strict; ${ $self->class . '::VERSION' } }; my $help_brief = $self->help_brief; - my $datetime = $self->__context__->now; + my $datetime = $self->__context__->build_time; my ($date,$time) = split(' ',$datetime); push(@sections, UR::Doc::Section->create( --- a/lib/UR/Context.pm +++ b/lib/UR/Context.pm @@ -137,6 +137,14 @@ sub now { return Date::Format::time2str(date_template(), time()); } +sub build_time { + return Date::Format::time2str( + date_template(), + $ENV{SOURCE_DATE_EPOCH} || time(), + 'UTC' + ); +} + my $master_monitor_query = 0; sub monitor_query { return if $UR::Object::Type::bootstrapping;