Use GNOME odd/even version numbering to detect if running -dev

Since switching to the GNOME release schedule, we need to do unstable
releases off of mainline, which means we need to update the version
number (and drop the "-dev" suffix) so tarballs etc get the right
version.

Instead of looking for the -dev suffix, parse the version number
to determine if we should display the revision in About.
This commit is contained in:
Michael Gratton 2019-04-28 17:55:59 +10:00
parent 8022ffecce
commit 322bdd2d42
5 changed files with 70 additions and 27 deletions

View file

@ -182,9 +182,13 @@ conf.set_quoted('_WEB_EXTENSIONS_DIR', web_extensions_dir)
conf.set_quoted('LANGUAGE_SUPPORT_DIRECTORY', locale_dir) conf.set_quoted('LANGUAGE_SUPPORT_DIRECTORY', locale_dir)
conf.set_quoted('ISO_CODE_639_XML', iso_639_xml) conf.set_quoted('ISO_CODE_639_XML', iso_639_xml)
conf.set_quoted('ISO_CODE_3166_XML', iso_3166_xml) conf.set_quoted('ISO_CODE_3166_XML', iso_3166_xml)
conf.set('HAVE_FTS3_TOKENIZE', true)
conf.set('VERSION', meson.project_version())
conf.set('GCR_API_SUBJECT_TO_CHANGE', true) conf.set('GCR_API_SUBJECT_TO_CHANGE', true)
conf.set('HAVE_FTS3_TOKENIZE', true)
# geary-version.vala.in gets configured twice (once for the version,
# once for the revision), so make sure the revision template carries
# through to the second time.
conf.set('REVISION', '@REVISION@')
conf.set('VERSION', meson.project_version())
configure_file(output: 'config.h', configuration: conf) configure_file(output: 'config.h', configuration: conf)
# Post-install scripts # Post-install scripts

View file

@ -28,7 +28,7 @@ public class GearyApplication : Gtk.Application {
public const string WEBSITE_LABEL = _("Visit the Geary web site"); public const string WEBSITE_LABEL = _("Visit the Geary web site");
public const string BUGREPORT = "https://wiki.gnome.org/Apps/Geary/ReportingABug"; public const string BUGREPORT = "https://wiki.gnome.org/Apps/Geary/ReportingABug";
public const string VERSION = Geary.Version.GEARY_VERSION; public const string VERSION = Geary.Version.NUMBER;
public const string INSTALL_PREFIX = _INSTALL_PREFIX; public const string INSTALL_PREFIX = _INSTALL_PREFIX;
public const string GSETTINGS_DIR = _GSETTINGS_DIR; public const string GSETTINGS_DIR = _GSETTINGS_DIR;
public const string SOURCE_ROOT_DIR = _SOURCE_ROOT_DIR; public const string SOURCE_ROOT_DIR = _SOURCE_ROOT_DIR;
@ -66,6 +66,7 @@ public class GearyApplication : Gtk.Application {
// Local-only command line options // Local-only command line options
private const string OPTION_VERSION = "version"; private const string OPTION_VERSION = "version";
private const string OPTION_VERSION_FULL = "version-full";
// Local command line options // Local command line options
private const string OPTION_DEBUG = "debug"; private const string OPTION_DEBUG = "debug";
@ -146,6 +147,10 @@ public class GearyApplication : Gtk.Application {
/// Command line option /// Command line option
N_("Display program version"), null }, N_("Display program version"), null },
// Use this to specify arguments in the help section // Use this to specify arguments in the help section
{ OPTION_VERSION_FULL, 'V', 0, GLib.OptionArg.NONE, null,
/// Command line option
N_("Display program version and revision id"), null },
// Use this to specify arguments in the help section
{ GLib.OPTION_REMAINING, 0, 0, GLib.OptionArg.STRING_ARRAY, null, null, { GLib.OPTION_REMAINING, 0, 0, GLib.OptionArg.STRING_ARRAY, null, null,
"[mailto:[...]]" }, "[mailto:[...]]" },
{ null } { null }
@ -271,6 +276,7 @@ public class GearyApplication : Gtk.Application {
/// Application runtime information label /// Application runtime information label
info.add({ _("Geary version"), VERSION }); info.add({ _("Geary version"), VERSION });
info.add({ _("Geary revision"), Geary.Version.ID });
/// Application runtime information label /// Application runtime information label
info.add({ _("GTK version"), info.add({ _("GTK version"),
"%u.%u.%u".printf( "%u.%u.%u".printf(
@ -385,6 +391,14 @@ public class GearyApplication : Gtk.Application {
"%s: %s\n", this.binary, GearyApplication.VERSION "%s: %s\n", this.binary, GearyApplication.VERSION
); );
return 0; return 0;
} else if (options.contains(OPTION_VERSION_FULL)) {
GLib.stdout.printf(
"%s: %s (%s)\n",
this.binary,
GearyApplication.VERSION,
Geary.Version.ID
);
return 0;
} }
return -1; return -1;
@ -469,6 +483,22 @@ public class GearyApplication : Gtk.Application {
public async void show_about() { public async void show_about() {
yield this.present(); yield this.present();
// Use just the version string for stable builds, i.e. those
// with even-numbered minor revisions like "3.32.0", but show
// the version number and revision for unstable builds
// i.e. those with odd-numbered minor revisions like "3.33.0"
string displayed_version = VERSION;
string[] version_parts = VERSION.split(".");
if (version_parts.length >= 2) {
int minor = int.parse(version_parts[1]);
if (minor % 2 == 1) {
displayed_version = "%s (%s)".printf(
Geary.Version.NUMBER,
Geary.Version.ID
);
}
}
Gtk.show_about_dialog(get_active_window(), Gtk.show_about_dialog(get_active_window(),
"program-name", NAME, "program-name", NAME,
"comments", DESCRIPTION, "comments", DESCRIPTION,
@ -476,7 +506,7 @@ public class GearyApplication : Gtk.Application {
"copyright", string.join("\n", COPYRIGHT_1, COPYRIGHT_2), "copyright", string.join("\n", COPYRIGHT_1, COPYRIGHT_2),
"license-type", Gtk.License.LGPL_2_1, "license-type", Gtk.License.LGPL_2_1,
"logo-icon-name", APP_ID, "logo-icon-name", APP_ID,
"version", VERSION, "version", displayed_version,
"website", WEBSITE, "website", WEBSITE,
"website-label", WEBSITE_LABEL, "website-label", WEBSITE_LABEL,
"title", _("About %s").printf(NAME), "title", _("About %s").printf(NAME),
@ -674,8 +704,11 @@ public class GearyApplication : Gtk.Application {
lock (this.controller) { lock (this.controller) {
if (this.controller == null) { if (this.controller == null) {
message( message(
"%s %s prefix=%s exec_dir=%s is_installed=%s", "%s %s (%s) prefix=%s exec_dir=%s is_installed=%s",
NAME, VERSION, INSTALL_PREFIX, NAME,
VERSION,
Geary.Version.ID,
INSTALL_PREFIX,
exec_dir.get_path(), exec_dir.get_path(),
this.is_installed.to_string() this.is_installed.to_string()
); );

View file

@ -409,7 +409,7 @@ class ImapConsole : Gtk.Window {
Gee.HashMap<string, string> fields = new Gee.HashMap<string, string>(); Gee.HashMap<string, string> fields = new Gee.HashMap<string, string>();
fields.set("name", "geary-console"); fields.set("name", "geary-console");
fields.set("version", Geary.Version.GEARY_VERSION); fields.set("version", Geary.Version.NUMBER);
this.cx.send_command(new Geary.Imap.IdCommand(fields)); this.cx.send_command(new Geary.Imap.IdCommand(fields));
} }

View file

@ -1,9 +1,18 @@
/* Copyright 2016 Software Freedom Conservancy Inc. /*
* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2019 Michael Gratton <mike@vee.net>
* *
* This software is licensed under the GNU Lesser General Public License * This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
/** Provides access to Engine version and revision numbers. */
namespace Geary.Version { namespace Geary.Version {
public const string GEARY_VERSION = "@VERSION@";
} /** The current version number for this build. */
public const string NUMBER = "@VERSION@";
/** The source code identifier for this build. */
public const string ID = "@REVISION@";
}

View file

@ -1,21 +1,18 @@
# Version # Version
if meson.project_version().endswith('-dev') geary_version_in = configure_file(
# Development build input: 'geary-version.vala.in',
geary_version_vala = vcs_tag( output: 'geary-version.vala.in',
command: '../build-aux/git_version.py', configuration: conf,
input: 'geary-version.vala.in', install: false
output: 'geary-version.vala', )
replace_string: '@VERSION@'
) geary_version_vala = vcs_tag(
else command: '../build-aux/git_version.py',
# Release build input: geary_version_in,
geary_version_vala = configure_file( output: 'geary-version.vala',
input: 'geary-version.vala.in', replace_string: '@REVISION@'
output: 'geary-version.vala', )
configuration: conf,
)
endif
# Common vala options # Common vala options
geary_vala_options = [ geary_vala_options = [