Skip to content
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

Pre-Commit Hook to generate Version Triple #50

Open
MaxClerkwell opened this issue Oct 25, 2023 · 6 comments
Open

Pre-Commit Hook to generate Version Triple #50

MaxClerkwell opened this issue Oct 25, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@MaxClerkwell
Copy link
Contributor

After #49 the version-number gets compilied into OmniView. The version-triplet can be set by manipulating the CMakeLists.txt.

Another approach could be to utilize a script and a pre-commit hook such as:

#!/bin/bash

# get tag from commit
tag=$(git log -1 --pretty=%D | awk '{split($0, a, ", "); print a[1]}' | sed 's/refs\/tags\///')

# set version to tiple
awk -v tag="$tag" '/^project/ { sub(/VERSION [0-9]+\.[0-9]+\.[0-9]+/, "VERSION " tag) }1' CMakeLists.txt > CMakeLists.txt.tmp
mv CMakeLists.txt.tmp CMakeLists.txt

# add manipulated cmakelists.txt
git add CMakeLists.txt

After running chmod +x on the file and adding it to .git/hooks this should potentially work when running

git tag -a v1.2.3 -m "Version 1.2.3"

Any opinions?

@MaxClerkwell MaxClerkwell added the enhancement New feature or request label Oct 25, 2023
@rkta
Copy link

rkta commented Oct 25, 2023 via email

@MaxClerkwell
Copy link
Contributor Author

Version triple is only necessary for release build in CI I guess, so one could generate the version triple from the tag in CMake as shown below maybe:

execute_process(
    COMMAND git describe --tags --exact-match
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    RESULT_VARIABLE TAG_RESULT
    OUTPUT_VARIABLE TAG_NAME
    ERROR_QUIET
    OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(TAG_RESULT EQUAL 0)
    message("Commit has Tag: ${TAG_NAME}")
else()
    message("Commit has no Tag.")
endif()

What should happen in the case, that something is pushed and build in CI without being tagged?

@rkta
Copy link

rkta commented Oct 26, 2023 via email

@MaxClerkwell
Copy link
Contributor Author

I disagree here. Version is only necessary. Someone might make a build from master in a hurry, because some other one needs to show something to the customer. You want to know which version that was afterwards.

But wouldn't that build be better identified by the Commit-Hash, while the Commit-Hash wouldn't be suitable for a customer-release? Or am I mistaken here what a version-number is good for?

Furthermore I am torn whether or not, OmniView should be buildable locally or only via CI. I mean, I get it, building locally is a good thing, but there is driver-code in one of the submodules, that we don't want to distribute anyways.

Not sure how to deal with that, yet.

@rkta
Copy link

rkta commented Oct 27, 2023 via email

@AKMaily
Copy link
Collaborator

AKMaily commented May 16, 2024

Now that we have a release version, this issue should be resolved. @bjoekeldude .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants