Repository navigation
Baf 1402/parse version file #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0b0993d
66ea4a9
576932a
7a6f9c1
ea9a5dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,11 +108,39 @@ ENDFUNCTION() | |
|
|
||
| ## | ||
| # | ||
| # Locate ${CMAKE_CURRENT_LIST_DIR}/version.txt, | ||
| # Locate ${CMAKE_CURRENT_SOURCE_DIR}/version.txt, and parse the version. | ||
| # The version is expected to be defined as a key-value `version=X.Y.Z` | ||
| # | ||
| # If the version.txt file doesn't exist, or doesn't contain version key-value, an error occurs | ||
| # | ||
| # <function>( | ||
| # <output_var> | ||
| # ) | ||
| FUNCTION(CMUTIL_VERSION_GET_FROM_VERSION_FILE output_var) | ||
| SET(version_file ${ARGN}) | ||
| IF("${version_file}" STREQUAL "") | ||
| SET(version_file "${CMAKE_CURRENT_SOURCE_DIR}/version.txt") | ||
| ENDIF() | ||
|
|
||
| SET(inject_version "") | ||
| CMUTIL_PROPERTY_FILE_READ("${version_file}" inject) | ||
| IF(NOT DEFINED inject_version OR "${inject_version}" STREQUAL "") | ||
| MESSAGE(FATAL_ERROR "${version_file} is not valid") | ||
| ENDIF() | ||
| CMUTIL_VERSION_CHECK("${inject_version}") | ||
|
|
||
| SET(${output_var} "${inject_version}" PARENT_SCOPE) | ||
| ENDFUNCTION() | ||
|
|
||
|
|
||
|
|
||
| ## | ||
| # | ||
| # Locate ${CMAKE_CURRENT_SOURCE_DIR}/version.txt, | ||
| # read the first line and compare version stored in version.txt | ||
| # with ${version}. | ||
| # | ||
| # If versions does not match error occurres. | ||
| # If versions does not match error occurs. | ||
|
Comment on lines
+137
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -A25 -B3 \
'FUNCTION\(CMUTIL_PROPERTY_FILE_READ' \
. --glob '*.cmake'Repository: cmakelib/cmakelib-component-cmutil Length of output: 1539 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- CMUTIL_VERSION.cmake ---'
cat -n system_modules/CMUTIL_VERSION.cmake | sed -n '1,180p'
printf '%s\n' '--- property-file call sites and version files ---'
rg -n -C4 \
'CMUTIL_VERSION_GET_FROM_VERSION_FILE|CMUTIL_PROPERTY_FILE_READ|version=' \
. --glob '*.cmake' --glob 'version.txt' --glob '*.txt'Repository: cmakelib/cmakelib-component-cmutil Length of output: 11617 Document the
🤖 Prompt for AI Agents |
||
| # | ||
| # <function>( | ||
| # <version> | ||
|
|
@@ -124,11 +152,12 @@ FUNCTION(CMUTIL_VERSION_VALIDATE_VERSION_FILE_FOR version) | |
| SET(version_file "${CMAKE_CURRENT_SOURCE_DIR}/version.txt") | ||
| ENDIF() | ||
|
|
||
| SET(inject_version "") | ||
| CMUTIL_PROPERTY_FILE_READ("${version_file}" inject) | ||
| IF(NOT inject_version) | ||
| IF(NOT DEFINED inject_version OR "${inject_version}" STREQUAL "") | ||
| MESSAGE(FATAL_ERROR "${version_file} is not valid") | ||
| ENDIF() | ||
| CMUTIL_VERSION_CHECK(${inject_version}) | ||
| CMUTIL_VERSION_CHECK("${inject_version}") | ||
| IF(NOT version STREQUAL inject_version) | ||
| MESSAGE(FATAL_ERROR "${version_file} is not in sync with current branch (${version} vs. ${inject_version})") | ||
| ENDIF() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| # Test | ||
|
|
||
| ## Run | ||
|
|
||
| For tests go to the `test/` directory and run | ||
|
|
||
| Linux/Mac Os: | ||
|
|
||
| ``` | ||
| git clean -xfd . | ||
| cmake . | ||
| git clean -xfd . | ||
| cmake -P ./CMakeLists.txt | ||
| ``` | ||
|
|
||
| Windows PowerShell: | ||
|
|
||
| ``` | ||
| git clean -xfd . | ||
| cmake . | ||
| git clean -xfd . | ||
| cmake -P ./CMakeLists.txt | ||
| ``` | ||
|
|
||
| then just clean up all intermediate files in `test/` directory by | ||
|
|
||
| ``` | ||
| git clean -xfd . | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: cmakelib/cmakelib-component-cmutil
Length of output: 7031
🏁 Script executed:
Repository: cmakelib/cmakelib-component-cmutil
Length of output: 16259
🏁 Script executed:
Repository: cmakelib/cmakelib-component-cmutil
Length of output: 193
🏁 Script executed:
Repository: cmakelib/cmakelib-component-cmutil
Length of output: 580
Reject versions outside the documented
X.Y.Zformat.CMUTIL_VERSION_CHECKaccepts1.58and values such as1.58.3-devby matching only a valid prefix. Require an anchored match with a mandatory patch component, or document and support these formats.🤖 Prompt for AI Agents