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()