]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Get SOURCE_EPOCH from the latest git tag instead of NEWS
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 20 Jul 2020 19:41:48 +0000 (20:41 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2020 06:38:30 +0000 (08:38 +0200)
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

index 020a7e55ce8f8be16806978a410a50d153760219..0c0e1343c175f5957458d2d90334dd886868aff4 100644 (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()