From 85f0d38ab5ffada4b05711959df2d351093d8b04 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 19 Apr 2024 17:59:19 +0200 Subject: [PATCH] Use tag timestamp instead of current timestamp when SOURCE_DATE_EPOCH is not set --- build/scripts/phar-set-timestamps/run.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/scripts/phar-set-timestamps/run.php b/build/scripts/phar-set-timestamps/run.php index 7289ad53c3e..710684f8d58 100755 --- a/build/scripts/phar-set-timestamps/run.php +++ b/build/scripts/phar-set-timestamps/run.php @@ -8,15 +8,15 @@ use Seld\PharUtils\Timestamps; -$util = new Timestamps($argv[1]); - if (is_string(getenv('SOURCE_DATE_EPOCH'))) { - $timestamp = new DateTime; - $timestamp->setTimestamp((int) getenv('SOURCE_DATE_EPOCH')); + $epoch = (int) getenv('SOURCE_DATE_EPOCH'); } else { - $timestamp = new DateTimeImmutable('now'); + $epoch = (int) trim(shell_exec('git log -1 --format=%at ' . trim(shell_exec('git describe --abbrev=0')))); } -$util->updateTimestamps($timestamp); +$timestamp = new DateTime; +$timestamp->setTimestamp($epoch); +$util = new Timestamps($argv[1]); +$util->updateTimestamps($timestamp); $util->save($argv[1], Phar::SHA512);