[epiphany] Use meson's vcs_tag(), but not for network requests



commit 4c34c7e1b13148f1aa9997148cb1bb8f9b3416cc
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jan 15 07:26:44 2018 -0600

    Use meson's vcs_tag(), but not for network requests
    
    I just learned about meson's vcs_tag() function. We can use this to get
    rid of our compute-tech-preview-version.sh script.
    
    In implementing this, I discovered that we're sending the git hash along
    to the sync server and safe browsing server. Let's not do that. Only use
    the VCS version when displaying things locally, not in network requests.

 compute-tech-preview-version.sh |   10 ----------
 embed/ephy-about-handler.c      |    3 ++-
 ephy-vcs-version.h.in           |    1 +
 meson.build                     |   28 ++++++++++++++++++----------
 src/ephy-main.c                 |    3 ++-
 src/window-commands.c           |    3 ++-
 6 files changed, 25 insertions(+), 23 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index 9126f5d..8459c78 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -31,6 +31,7 @@
 #include "ephy-settings.h"
 #include "ephy-smaps.h"
 #include "ephy-snapshot-service.h"
+#include "ephy-vcs-version.h"
 #include "ephy-web-app-utils.h"
 
 #include <gio/gio.h>
@@ -270,7 +271,7 @@ ephy_about_handler_handle_about (EphyAboutHandler       *handler,
   char *version;
   GtkIconInfo *icon_info;
 
-  version = g_strdup_printf (_("Version %s"), VERSION);
+  version = g_strdup_printf (_("Version %s"), VCSVERSION);
 
   icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
                                           "org.gnome.Epiphany",
diff --git a/ephy-vcs-version.h.in b/ephy-vcs-version.h.in
new file mode 100644
index 0000000..b72001f
--- /dev/null
+++ b/ephy-vcs-version.h.in
@@ -0,0 +1 @@
+#define VCSVERSION "@VCSVERSION@"
diff --git a/meson.build b/meson.build
index afa06cc..71f0a32 100644
--- a/meson.build
+++ b/meson.build
@@ -40,22 +40,30 @@ conf.set10('DEVELOPER_MODE', get_option('developer_mode'))
 tech_preview = get_option('tech_preview')
 conf.set10('TECH_PREVIEW', tech_preview)
 
-if tech_preview
-  msg = 'Computing Epiphany Tech Preview version: '
-  res = run_command(join_paths(meson.source_root(), 'compute-tech-preview-version.sh'))
-  assert(res.returncode() == 0, msg + 'FAIL (script returned nonzero exit status)')
-  tech_preview_version = res.stdout().strip()
-  message(msg + tech_preview_version)
-  conf.set_quoted('VERSION', tech_preview_version)
-else
-  conf.set_quoted('VERSION', meson.project_version())
-endif
+conf.set_quoted('VERSION', meson.project_version())
 
 configure_file(
   output: 'config.h',
   configuration: conf
 )
 
+if tech_preview
+  vcs_tag(
+    input: 'ephy-vcs-version.h.in',
+    output: 'ephy-vcs-version.h',
+    replace_string: '@VCSVERSION@'
+  )
+else
+  version_conf = configuration_data()
+  version_conf.set('VCSVERSION', meson.project_version())
+
+  configure_file(
+    input: 'ephy-vcs-version.h.in',
+    output: 'ephy-vcs-version.h',
+    configuration: version_conf
+  )
+endif
+
 glib_requirement = '>= 2.52.0'
 gtk_requirement = '>= 3.22.13'
 nettle_requirement = '>= 3.2'
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 9c4687e..3211950 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -29,6 +29,7 @@
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-string.h"
+#include "ephy-vcs-version.h"
 #include "ephy-web-app-utils.h"
 
 #include <errno.h>
@@ -99,7 +100,7 @@ option_version_cb (const gchar *option_name,
                    gpointer     data,
                    GError     **error)
 {
-  g_print ("%s %s\n", _("Web"), VERSION);
+  g_print ("%s %s\n", _("Web"), VCSVERSION);
 
   exit (EXIT_SUCCESS);
   return FALSE;
diff --git a/src/window-commands.c b/src/window-commands.c
index 5c57aa1..374a3cb 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -52,6 +52,7 @@
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-string.h"
+#include "ephy-vcs-version.h"
 #include "ephy-web-app-utils.h"
 #include "ephy-zoom.h"
 
@@ -651,7 +652,7 @@ window_cmd_show_about (GSimpleAction *action,
 #else
                          "program-name", _("Epiphany Technology Preview"),
 #endif
-                         "version", VERSION,
+                         "version", VCSVERSION,
                          "copyright", "Copyright © 2002–2004 Marco Pesenti Gritti\n"
                          "Copyright © 2003–2018 The Web Developers",
                          "artists", artists,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]