|
29 | 29 | SET(VERSION_MINOR {minor}) |
30 | 30 | SET(VERSION_PATCH {patch}) |
31 | 31 | SET(VERSION_GITHASH {githash}) |
| 32 | +SET(VERSION_TWEAK {tweak}) |
32 | 33 | SET(VERSION_DESCRIBE {describe}) |
33 | 34 | SET(VERSION_STRING {string}) |
34 | 35 | # end of autochange |
@@ -302,18 +303,29 @@ def get_version_from_repo( |
302 | 303 | ) |
303 | 304 |
|
304 | 305 | # if this commit is tagged, use tag's version instead of something stored in cmake |
305 | | - if git is not None and git.latest_tag and git.commits_since_latest == 0: |
| 306 | + if git is not None and git.latest_tag: |
306 | 307 | version_from_tag = get_version_from_tag(git.latest_tag) |
307 | | - # Tag has a priority over the version written in CMake. |
308 | | - # Version must match (except tweak, flavour, description, etc.) to avoid accidental mess. |
309 | | - if not (version_from_tag.major == cmake_version.major \ |
310 | | - and version_from_tag.minor == cmake_version.minor \ |
311 | | - and version_from_tag.patch == cmake_version.patch): |
312 | | - raise RuntimeError(f"Version generated from tag ({version_from_tag}) should have same major, minor, and patch values as version generated from cmake ({cmake_version})") |
313 | | - |
314 | | - # Don't need to reset version completely, mostly because revision part is not set in tag, but must be preserved |
315 | | - cmake_version._flavour = version_from_tag._flavour |
316 | | - cmake_version.tweak = version_from_tag.tweak |
| 308 | + logging.debug(f'Git latest tag: {git.latest_tag} ({git.commits_since_latest} commits ago)\n' |
| 309 | + f'"new" tag: {git.new_tag} ({git.commits_since_new})\n' |
| 310 | + f'current commit: {git.sha}\n' |
| 311 | + f'current brach: {git.branch}' |
| 312 | + ) |
| 313 | + if git.commits_since_latest == 0: |
| 314 | + # Tag has a priority over the version written in CMake. |
| 315 | + # Version must match (except tweak, flavour, description, etc.) to avoid accidental mess. |
| 316 | + if not (version_from_tag.major == cmake_version.major \ |
| 317 | + and version_from_tag.minor == cmake_version.minor \ |
| 318 | + and version_from_tag.patch == cmake_version.patch): |
| 319 | + raise RuntimeError(f"Version generated from tag ({version_from_tag}) should have same major, minor, and patch values as version generated from cmake ({cmake_version})") |
| 320 | + |
| 321 | + # Don't need to reset version completely, mostly because revision part is not set in tag, but must be preserved |
| 322 | + logging.debug(f"Resetting TWEAK and FLAVOUR of version from cmake {cmake_version} to values from tag: {version_from_tag.tweak}.{version_from_tag._flavour}") |
| 323 | + cmake_version._flavour = version_from_tag._flavour |
| 324 | + cmake_version.tweak = version_from_tag.tweak |
| 325 | + else: |
| 326 | + # We've had some number of commits since the latest tag. |
| 327 | + logging.debug(f"Bumping the TWEAK of version from cmake {cmake_version} by {git.commits_since_latest}") |
| 328 | + cmake_version.tweak = cmake_version.tweak + git.commits_since_latest |
317 | 329 |
|
318 | 330 | return cmake_version |
319 | 331 |
|
|
0 commit comments