Always compute UI_EXTENSION_GIT_SHA

This commit is contained in:
Yves
2025-02-17 18:20:25 +01:00
parent 1698c5cb7c
commit d03b87dfce
3 changed files with 19 additions and 5 deletions

View File

@@ -25,6 +25,20 @@ set(EXTENSION_SOURCES
src/utils/serialization.cpp
)
find_package(Git)
if (NOT Git_FOUND)
message(FATAL_ERROR "Git not found, unable to determine git sha")
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short=10 HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE UI_EXTENSION_GIT_SHA
)
message(STATUS "UI_EXTENSION_GIT_SHA=${UI_EXTENSION_GIT_SHA}")
add_definitions(-DUI_EXTENSION_GIT_SHA="${UI_EXTENSION_GIT_SHA}")
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})

View File

@@ -94,10 +94,10 @@ bool HttpServer::Start(const uint16_t local_port, const std::string &remote_url,
local_port_ = local_port;
remote_url_ = remote_url;
ddb_instance_ = ddb_instance;
#ifndef EXT_VERSION_UI
#error "EXT_VERSION_UI must be defined"
#ifndef UI_EXTENSION_GIT_SHA
#error "UI_EXTENSION_GIT_SHA must be defined"
#endif
user_agent_ = StringUtil::Format("duckdb-ui/%s(%s)", EXT_VERSION_UI, DuckDB::Platform());
user_agent_ = StringUtil::Format("duckdb-ui/%s(%s)", UI_EXTENSION_GIT_SHA, DuckDB::Platform());
event_dispatcher_ = make_uniq<EventDispatcher>();
thread_ = make_uniq<std::thread>(&HttpServer::Run, this);
return true;

View File

@@ -115,8 +115,8 @@ std::string UiExtension::Name() {
}
std::string UiExtension::Version() const {
#ifdef EXT_VERSION_UI
return EXT_VERSION_UI;
#ifdef UI_EXTENSION_GIT_SHA
return UI_EXTENSION_GIT_SHA;
#else
return "";
#endif