From ddda37f75d2c50668b169f345fc5278132bf0013 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sun, 4 Feb 2024 04:03:43 +0100 Subject: [PATCH] Remove the emergency version and commit ID When the version system was designed, we envisioned two types of release: * Stable releases 3.0, 3.1, 3.2, etc. * Pre-releases 3.0-alpha.1 etc. In addition, we wanted to show a commit id in various places for intermediate builds. The code was written to change the C++ side of things as little as possible, which resulted in some hacks being used. In practice, we don't strictly follow this scheme since we publish patch releases to the stable, e.g. 3.0.2. This patch removes a hack and code we don't need: * Support for emergency versions (we just release a new minor if needed) * Support for commit SHAs (it was hacky) The release documentation is also updated with the new expected tag format (three digits without -stable for stable releases). --- CMakeLists.txt | 25 ++++++++++--------------- client/packhand.cpp | 2 +- common/networking/packets.def | 5 +++-- docs/Contributing/release.rst | 7 ++++--- server/connecthand.cpp | 2 +- server/savegame/savegame3.cpp | 1 - utility/fc_version.h.in | 16 ++++++---------- 7 files changed, 25 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8ac627aea..80ae30da80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,28 +39,23 @@ include(AutoRevision) # Set some variables from AutoRevision for use here and later list(LENGTH FC21_REV_TAG_LIST FC21_REV_TAG_LIST_LENGTH) -# When we tag a stable release we only get 2 of the 4 components populated -# So we manually set some of the variables we need for the full version. -if(${FC21_REV_TAG_LIST_LENGTH} EQUAL 2) +# When we tag a stable release we only get 3 of the 4 components populated, +# so we manually set some of the variables we need for the full version. +if (${FC21_REV_TAG_LIST_LENGTH} EQUAL 3) list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION) list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION) - set(FC21_LABEL_VERSION "Stable") - set(FC21_EMER_VERSION "0") - set(FC21_PATCH_VERSION "0") + list(GET FC21_REV_TAG_LIST 2 FC21_PATCH_VERSION) + set(FC21_VERSION_LABEL "stable") set(IS_STABLE_VERSION true) - set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}") + set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}") else() + message(STATUS "${FC21_REV_TAG_LIST}") list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION) list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION) - list(GET FC21_REV_TAG_LIST 2 FC21_LABEL_VERSION) - if (${FC21_REV_TAG_LIST_LENGTH} GREATER 3) - list(GET FC21_REV_TAG_LIST 3 FC21_EMER_VERSION) - else() - set(FC21_EMER_VERSION 0) - endif() - set(FC21_PATCH_VERSION ${FC21_REV_HEAD_HASH_D}) + list(GET FC21_REV_TAG_LIST 2 FC21_VERSION_LABEL) + list(GET FC21_REV_TAG_LIST 3 FC21_PATCH_VERSION) set(IS_STABLE_VERSION false) - set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}") + set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}") endif() # Set project diff --git a/client/packhand.cpp b/client/packhand.cpp index 5e483a2d03..04438c3f22 100644 --- a/client/packhand.cpp +++ b/client/packhand.cpp @@ -353,7 +353,7 @@ void handle_server_join_reply(bool you_can_join, const char *message, } client_info._obsolete = 5; // Old value for gui_type(GUI_QT) - client_info.emerg_version = EMERGENCY_VERSION; + client_info._obsolete2 = 0; qstrncpy(client_info.distribution, FREECIV_DISTRIBUTOR, sizeof(client_info.distribution)); send_packet_client_info(&client.conn, &client_info); diff --git a/common/networking/packets.def b/common/networking/packets.def index 214c214f30..d61cd62b4f 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -665,7 +665,8 @@ end PACKET_SERVER_INFO = 29; sc, dsend STRING version_label[48]; - UINT32 major_version, minor_version, patch_version, emerg_version; + UINT32 major_version, minor_version, patch_version; + UINT32 _obsolete; # Since 3.1 end /************** City packets **********************/ @@ -1291,7 +1292,7 @@ end PACKET_CLIENT_INFO = 119; cs, handle-per-conn UINT8 _obsolete; - UINT32 emerg_version; + UINT32 _obsolete2; # Since 3.1 STRING distribution[MAX_LEN_NAME]; end diff --git a/docs/Contributing/release.rst b/docs/Contributing/release.rst index a736aefecd..8b42266ee2 100644 --- a/docs/Contributing/release.rst +++ b/docs/Contributing/release.rst @@ -41,15 +41,16 @@ These are the general steps to prepare and finalize a release: `branches page `_. #. From the same page, create a new ``stable`` branch from ``master``. #. Update ``cmake/AutoRevision.txt`` with the hash of the last commit in ``master`` and - ``v[major version].[minor version]-dev`` with the version of the :strong:`next stable release`, then + ``v[major version].[minor version]-dev.0`` with the version of the :strong:`next stable release`, then open a PR for this change to ``master``. This way, development builds from ``master`` will immediately use the version number of the next stable. #. If the release is a :strong:`release candidate` for a :strong:`stable release`, the release manager will make sure that the :guilabel:`Target` branch in the release draft is set to ``stable``. #. The release manager will add a tag to the release notes page and then click :guilabel:`Publish Release`. - The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]``. For example: - ``v3.0-beta.6``. :strong:`The format is very important` to the build configuration process. + The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]`` for pre-releases + and ``v[major version].[minor version].[patch version]`` for stable versions. For example: + ``v3.0-beta.6`` or ``v3.1.0``. :strong:`The format is very important` to the build configuration process. #. After a few minutes the continuous integration (CI) will open a PR titled ``Release Update of AutoRevision.txt``. The release manager will open the PR, click on the :guilabel:`Close pull request` button, and then click :guilabel:`Open pull request` button. This is a diff --git a/server/connecthand.cpp b/server/connecthand.cpp index e6e5bfbc27..9b7daef6ac 100644 --- a/server/connecthand.cpp +++ b/server/connecthand.cpp @@ -399,7 +399,7 @@ bool handle_login_request(struct connection *pconn, info.major_version = MAJOR_VERSION; info.minor_version = MINOR_VERSION; info.patch_version = PATCH_VERSION; - info.emerg_version = EMERGENCY_VERSION; + info._obsolete = 0; sz_strlcpy(info.version_label, VERSION_LABEL); send_packet_server_info(pconn, &info); } diff --git a/server/savegame/savegame3.cpp b/server/savegame/savegame3.cpp index 119f4471df..e5b7396b00 100644 --- a/server/savegame/savegame3.cpp +++ b/server/savegame/savegame3.cpp @@ -2375,7 +2375,6 @@ static void sg_save_scenario(struct savedata *saving) game_version = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000 + PATCH_VERSION * 100; - game_version += EMERGENCY_VERSION; secfile_insert_int(saving->file, game_version, "scenario.game_version"); if (!saving->scenario || !game.scenario.is_scenario) { diff --git a/utility/fc_version.h.in b/utility/fc_version.h.in index 04673e0ce7..734bad4149 100644 --- a/utility/fc_version.h.in +++ b/utility/fc_version.h.in @@ -3,17 +3,13 @@ #define MAJOR_VERSION @FC21_MAJOR_VERSION@ #define MINOR_VERSION @FC21_MINOR_VERSION@ #define PATCH_VERSION @FC21_PATCH_VERSION@ -#define EMERGENCY_VERSION @FC21_EMER_VERSION@ -#ifndef VERSION_LABEL -#define VERSION_LABEL "-@FC21_LABEL_VERSION@" -#endif +#define VERSION_LABEL "-@FC21_VERSION_LABEL@" + #cmakedefine01 IS_STABLE_VERSION -#ifndef VERSION_STRING -# if IS_STABLE_VERSION -# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@" -# else // IS_STABLE_VERSION -# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@.@FC21_EMER_VERSION@-@FC21_LABEL_VERSION@" -# endif +#if IS_STABLE_VERSION +# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@" +#else // IS_STABLE_VERSION +# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@-@FC21_VERSION_LABEL@.@FC21_PATCH_VERSION@" #endif #define NETWORK_CAPSTRING \