From bd190899bba3f1d24663168f2e15e8697b7c4db9 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 20 Jul 2020 20:41:48 +0100 Subject: [PATCH] Get SOURCE_EPOCH from the latest git tag instead of NEWS Currently, each change to NEWS triggers a meson reconfigure that changes SOURCE_EPOCH which causes a full rebuild. Since NEWS changes relatively often, we have a full rebuild each time we pull from master even if we pull semi-regularly. This is further compounded when using branches since NEWS has a relatively high chance to differ between branches which causes git to update the modification time, leading to a full rebuild when switching between branches. We fix this by using the creation time of the latest git tag instead. --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 020a7e55ce..0c0e1343c1 100644 --- a/meson.build +++ b/meson.build @@ -679,6 +679,10 @@ if time_epoch == -1 source_date_epoch = run_command('sh', ['-c', 'echo "$SOURCE_DATE_EPOCH"']).stdout().strip() if source_date_epoch != '' time_epoch = source_date_epoch.to_int() + elif git.found() and run_command('test', '-e', '.git').returncode() == 0 + # If we're in a git repository, use the creation time of the latest git tag. + latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip() + time_epoch = run_command('git', 'log', '-1', '--format=%at', latest_tag).stdout().to_int() else NEWS = files('NEWS') time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout().to_int()