Skip to content

Commit

Permalink
feat(version): add build field to vim.version()
Browse files Browse the repository at this point in the history
This exposes the full git hash of the build to the lua table, generated by CMake.

Closes #23863
  • Loading branch information
PriceHiller committed Jun 5, 2023
1 parent c1ee187 commit 2725d26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmake/GenerateVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ execute_process(
ERROR_QUIET
RESULT_VARIABLE RES)

execute_process(
COMMAND git --git-dir=${NVIM_SOURCE_DIR}/.git --work-tree=${NVIM_SOURCE_DIR} rev-parse HEAD
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE RES)

set(NVIM_VERSION_BUILD "#define NVIM_VERSION_BUILD \"${GIT_HASH}\"\n")
file(WRITE "${OUTPUT}" "${NVIM_VERSION_BUILD}")


if(RES)
message(STATUS "Using NVIM_VERSION: ${NVIM_VERSION}")
file(WRITE "${OUTPUT}" "")
Expand All @@ -33,7 +44,7 @@ endif()

if(NOT "${NVIM_VERSION_HASH}" STREQUAL "${CURRENT_VERSION_HASH}")
message(STATUS "Using NVIM_VERSION: ${NVIM_VERSION}")
file(WRITE "${OUTPUT}" "${NVIM_VERSION_STRING}")
file(APPEND "${OUTPUT}" "${NVIM_VERSION_STRING}")
if(WIN32)
configure_file("${OUTPUT}" "${OUTPUT}" NEWLINE_STYLE UNIX)
endif()
Expand Down
1 change: 1 addition & 0 deletions src/nvim/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,7 @@ Dictionary version_dict(void)
PUT(d, "major", INTEGER_OBJ(NVIM_VERSION_MAJOR));
PUT(d, "minor", INTEGER_OBJ(NVIM_VERSION_MINOR));
PUT(d, "patch", INTEGER_OBJ(NVIM_VERSION_PATCH));
PUT(d, "build", CSTR_AS_OBJ(NVIM_VERSION_BUILD));
PUT(d, "prerelease", BOOLEAN_OBJ(NVIM_VERSION_PRERELEASE[0] != '\0'));
PUT(d, "api_level", INTEGER_OBJ(NVIM_API_LEVEL));
PUT(d, "api_compatible", INTEGER_OBJ(NVIM_API_LEVEL_COMPAT));
Expand Down

0 comments on commit 2725d26

Please sign in to comment.