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.
This commit is contained in:
Daan De Meyer 2020-07-20 20:41:48 +01:00 committed by Lennart Poettering
parent 00b868e857
commit bd190899bb
1 changed files with 4 additions and 0 deletions

View File

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