From 918670b41a2896adbcd1b7f6a56614440ede9d81 Mon Sep 17 00:00:00 2001
From: Bruce Cowan <bruce.cowan@strath.ac.uk>
Date: Wed, 1 Jan 2020 21:08:14 +0000
Subject: [PATCH] Simplify copyright year and add VCS version to dialogue

---
 src/find_year.sh |  6 ------
 src/main.c       |  1 +
 src/meson.build  | 15 ++++++++++++---
 3 files changed, 13 insertions(+), 9 deletions(-)
 delete mode 100755 src/find_year.sh

diff --git a/src/find_year.sh b/src/find_year.sh
deleted file mode 100755
index cbab476..0000000
--- a/src/find_year.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-# SPDX-FileCopyrightText: 2018-2020 Bruce Cowan <bruce@bcowan.me.uk>
-#
-# SPDX-License-Identifier: CC0-1.0
-
-git log -1 --format=%cd --date=format:%Y
diff --git a/src/main.c b/src/main.c
index 52342e5..7f2d0a1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,6 +35,7 @@ about_activated (GSimpleAction *simple,
                            "license-type", GTK_LICENSE_LGPL_3_0,
                            "authors", authors,
                            "comments", "Rugby scores possiblities program",
+                           "version", PACKAGE_VERSION,
                            NULL);
 }
 
diff --git a/src/meson.build b/src/meson.build
index 6f16b3f..10a5d0c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2016-2018 Bruce Cowan <bruce@bcowan.me.uk>
+# SPDX-FileCopyrightText: 2016-2020 Bruce Cowan <bruce@bcowan.me.uk>
 #
 # SPDX-License-Identifier: CC0-1.0
 
@@ -9,8 +9,17 @@ conf.set('TRY_POINTS', get_option('try_points'))
 conf.set('UTRY_POINTS', get_option('utry_points'))
 conf.set('KICK_POINTS', get_option('kick_points'))
 
-year = run_command('find_year.sh').stdout().strip()
-conf.set_quoted('COPYRIGHT_YEAR', year)
+VCS_TAG = ''
+COPYRIGHT_YEAR = '?'
+
+git = find_program('git', required: false)
+if git.found()
+    VCS_TAG = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
+    COPYRIGHT_YEAR = run_command('git', 'log', '-1', '--format=%cd', '--date=format:%Y').stdout().strip()
+endif
+
+conf.set_quoted('PACKAGE_VERSION', VCS_TAG)
+conf.set_quoted('COPYRIGHT_YEAR', COPYRIGHT_YEAR)
 
 config_h = configure_file(configuration: conf, output: 'config.h')
 
-- 
GitLab