Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @marcfir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request updates the CMake build system to change how the project version is determined. Instead of reading a version from a project.properties file, it now dynamically fetches the version from Git tags, providing a more robust and automated versioning mechanism. This change ensures that the project's version is always up-to-date with the latest Git tag, with a fallback for cases where no tag is found.
Highlights
- Dynamic Versioning: The project version is now dynamically retrieved using
git describe --tags --abbrev=0, which pulls the latest tag as the version, replacing the static read fromproject.properties. - Version Fallback: A fallback mechanism has been added to set the project version to "0.0.0" if
git describedoes not return a valid version, ensuring a default is always available. - Consistent Version Usage: The
LIBOSAL_PACKAGE_VERSIONandLIBOSAL_VERSIONvariables are updated to consistently use the newly derived Git version, ensuring all version references are aligned.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request updates the CMake build system to derive the project version from git tags instead of a project.properties file. My review focuses on improving the robustness of this new versioning mechanism. I've identified two high-severity issues. First, the git command execution and version parsing logic is fragile and can fail silently or produce incorrect versions. Second, the raw git output is used to set some version variables, which can be empty on failure, leading to an empty version in the build. I've provided suggestions to handle errors gracefully, use a more accurate regular expression for parsing, and consistently use the sanitized version string which has a proper fallback.
| execute_process( | ||
| COMMAND git describe --tags --abbrev=0 | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
| OUTPUT_VARIABLE GIT_VER | ||
| ) | ||
| string(REGEX MATCH "([0-9]*.[0-9]*.[0-9]*).*" _ ${GIT_VER}) | ||
| set(PROJECT_VERSION ${CMAKE_MATCH_1}) | ||
| if("${PROJECT_VERSION}" STREQUAL "") | ||
| set(PROJECT_VERSION 0.0.0) | ||
| endif() |
There was a problem hiding this comment.
The current method of getting the version from git is not fully robust.
- The
execute_processcall doesn't check if thegitcommand was successful. This can happen ifgitis not installed or if this is not a git repository (e.g., a source archive). - The regex
([0-9]*.[0-9]*.[0-9]*).*is incorrect. The.matches any character, not a literal dot, and*allows empty version components. It also doesn't handle commonvprefixes in tags.
I suggest a more robust implementation that handles git command failures and uses a more accurate regex. This will also make the fallback to 0.0.0 more explicit.
execute_process(
COMMAND git describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VER
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(GIT_RESULT EQUAL 0)
string(REGEX MATCH "v?([0-9]+\\.[0-9]+\\.[0-9]+)" _ ${GIT_VER})
set(PROJECT_VERSION ${CMAKE_MATCH_1})
endif()
if(NOT PROJECT_VERSION)
set(PROJECT_VERSION 0.0.0)
endif()
| set(LIBOSAL_PACKAGE_VERSION "${GIT_VER}") | ||
| set(LIBOSAL_VERSION "${GIT_VER}") |
There was a problem hiding this comment.
Using ${GIT_VER} directly here is risky because it can be empty if the git describe command fails (e.g., not a git repo, or no tags). This would result in an empty version string for LIBOSAL_PACKAGE_VERSION and LIBOSAL_VERSION.
It's safer to use ${PROJECT_VERSION}, which is guaranteed to have a fallback value (e.g., 0.0.0) from the logic above. If you intend to keep the v prefix from the git tag, a more robust approach should be taken to construct a version variable with a proper fallback.
set(LIBOSAL_PACKAGE_VERSION "${PROJECT_VERSION}")
set(LIBOSAL_VERSION "${PROJECT_VERSION}")
|
hi marc, thanks for the pr. can you just have a look at the proposed changes from the gemini-code-assist? i'm not the cmake expert but i think they make sense. |
|
There is another simple way to handle the configuration file not found issue echo "VERSION = ${tagver}" >project.properties |
No description provided.