]> git.proxmox.com Git - mirror_lxc.git/commitdiff
meson: Fix on shallow git trees
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 7 Jun 2022 19:16:11 +0000 (15:16 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 7 Jun 2022 21:18:09 +0000 (17:18 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
meson.build

index 0fe5008abd29fe69cd28fb14a6f08f54df0b3fd8..e3b3761309338a9237982fbc301bc061a65ec30e 100644 (file)
@@ -225,10 +225,14 @@ git = find_program('git', required: false)
 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
 if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).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', check: true).stdout().strip()
-    time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
-else
-    # Fallback to current epoch.
+    latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip()
+    if latest_tag != ''
+      time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
+    endif
+endif
+
+# Fallback to current epoch.
+if time_epoch == ''
     time_epoch = run_command(date, '+%s', check: true).stdout()
 endif
 generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()