Skip to content

Commit 06ff6ae

Browse files
committed
Rework /version, don't show preview and ignored releases
1 parent 9aa4c76 commit 06ff6ae

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ lib/astc-encoder
9393
lib/shaderc
9494

9595
.DS_Store
96+
97+
# Auto-generated files
98+
src/utils/version.hpp

CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ execute_process(
99

1010
# Get the latest abbreviated commit hash of the working branch
1111
execute_process(
12-
COMMAND git --no-pager describe --tags --always --dirty
12+
COMMAND git --no-pager describe --tags --always --exclude "preview" --exclude "ign-*" --dirty
1313
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
14-
OUTPUT_VARIABLE GIT_COMMIT_HASH
14+
OUTPUT_VARIABLE GIT_VERSION
1515
OUTPUT_STRIP_TRAILING_WHITESPACE
1616
)
1717

18+
message(STATUS "Configuring file from: ${CMAKE_SOURCE_DIR}/src/utils/version.hpp.in")
19+
message(STATUS "Output file: ${CMAKE_SOURCE_DIR}/src/utils/version.hpp")
20+
21+
configure_file(
22+
${CMAKE_SOURCE_DIR}/src/utils/version.hpp.in
23+
${CMAKE_SOURCE_DIR}/src/utils/version.hpp
24+
@ONLY)
25+
26+
include_directories(${CMAKE_BINARY_DIR}/generated)
27+
1828
# root CMakeLists for the SuperTuxKart project
1929
project(SuperTuxKart)
2030
set(PROJECT_VERSION "git")
@@ -655,9 +665,6 @@ else()
655665
endif()
656666
endif()
657667
658-
target_compile_definitions(supertuxkart PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"")
659-
target_compile_definitions(supertuxkart PRIVATE "-DGIT_VERSION=\"${GIT_COMMIT_HASH}\"")
660-
661668
# check if linking against libatomic is required
662669
include(CheckCXXSourceCompiles)
663670
check_cxx_source_compiles("

src/network/protocols/command_manager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "utils/string_utils.hpp"
5151
#include "utils/team_manager.hpp"
5252
#include "utils/tournament.hpp"
53+
#include "utils/version.hpp"
5354

5455
#include <algorithm>
5556
#include <fstream>
@@ -623,13 +624,12 @@ void CommandManager::initCommands()
623624

624625
addTextResponse("description", getSettings()->getMotd());
625626
addTextResponse("moreinfo", getSettings()->getHelpMessage());
626-
std::string version = "1.3 k 210fff beta";
627-
#ifdef GIT_VERSION
628-
version = std::string(GIT_VERSION);
629-
#ifdef GIT_BRANCH
630-
version += ", branch " + std::string(GIT_BRANCH);
631-
#endif
632-
#endif
627+
628+
std::string version = Version::version();
629+
std::string branch = Version::branch();
630+
if (!branch.empty())
631+
version += ", branch " + branch;
632+
633633
addTextResponse("version", version);
634634
addTextResponse("clear", std::string(30, '\n'));
635635

0 commit comments

Comments
 (0)