From 122197f47593a4553f80dc0ee1b00cb0f874ae84 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 Sep 2023 11:47:28 +0100 Subject: [PATCH] [Rework] Breaking: return back to semver --- CMakeLists.txt | 4 +++- config.h.in | 2 ++ src/lua/lua_common.c | 14 +++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3db35b20..68a9d1f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,17 +9,19 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12 FATAL_ERROR) SET(RSPAMD_VERSION_MAJOR 3) SET(RSPAMD_VERSION_MINOR 7) +SET(RSPAMD_VERSION_PATCH 0) # Keep two digits all the time SET(RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR}0) SET(RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR}0) +SET(RSPAMD_VERSION_PATCH_NUM ${RSPAMD_VERSION_PATCH}0) IF (GIT_ID) SET(GIT_VERSION 1) SET(RSPAMD_ID "${GIT_ID}") ENDIF () -SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}") +SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}") PROJECT(rspamd VERSION "${RSPAMD_VERSION}" LANGUAGES C CXX ASM) diff --git a/config.h.in b/config.h.in index 44dc3cdf3..5b5461f4c 100644 --- a/config.h.in +++ b/config.h.in @@ -188,9 +188,11 @@ #define RSPAMD_VERSION_MAJOR "${RSPAMD_VERSION_MAJOR}" #define RSPAMD_VERSION_MINOR "${RSPAMD_VERSION_MINOR}" +#define RSPAMD_VERSION_PATCH "${RSPAMD_VERSION_PATCH}" #define RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR_NUM} #define RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR_NUM} +#define RSPAMD_VERSION_PATCH_NUM ${RSPAMD_VERSION_PATCH_NUM} #define RSPAMD_VERSION_BRANCH "${RSPAMD_VERSION_MAJOR}" diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index bafe8ea93..9bf9514f6 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -475,15 +475,20 @@ rspamd_lua_rspamd_version_numeric(lua_State *L) type = lua_tostring(L, 1); if (g_ascii_strcasecmp(type, "short") == 0) { version_num = RSPAMD_VERSION_MAJOR_NUM * 1000 + - RSPAMD_VERSION_MINOR_NUM * 100; + RSPAMD_VERSION_MINOR_NUM * 100 + + RSPAMD_VERSION_PATCH_NUM * 10; } else if (g_ascii_strcasecmp(type, "main") == 0) { version_num = RSPAMD_VERSION_MAJOR_NUM * 1000 + - RSPAMD_VERSION_MINOR_NUM * 100; + RSPAMD_VERSION_MINOR_NUM * 100 + + RSPAMD_VERSION_PATCH_NUM * 10; } else if (g_ascii_strcasecmp(type, "major") == 0) { version_num = RSPAMD_VERSION_MAJOR_NUM; } + else if (g_ascii_strcasecmp(type, "patch") == 0) { + version_num = RSPAMD_VERSION_PATCH_NUM; + } else if (g_ascii_strcasecmp(type, "minor") == 0) { version_num = RSPAMD_VERSION_MINOR_NUM; } @@ -511,7 +516,7 @@ rspamd_lua_rspamd_version(lua_State *L) "." RSPAMD_VERSION_MINOR; } else if (g_ascii_strcasecmp(type, "main") == 0) { - result = RSPAMD_VERSION_MAJOR "." RSPAMD_VERSION_MINOR; + result = RSPAMD_VERSION_MAJOR "." RSPAMD_VERSION_MINOR "." RSPAMD_VERSION_PATCH; } else if (g_ascii_strcasecmp(type, "major") == 0) { result = RSPAMD_VERSION_MAJOR; @@ -519,6 +524,9 @@ rspamd_lua_rspamd_version(lua_State *L) else if (g_ascii_strcasecmp(type, "minor") == 0) { result = RSPAMD_VERSION_MINOR; } + else if (g_ascii_strcasecmp(type, "patch") == 0) { + result = RSPAMD_VERSION_PATCH; + } else if (g_ascii_strcasecmp(type, "id") == 0) { result = RID; } -- 2.39.5