-
Notifications
You must be signed in to change notification settings - Fork 4
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
Comments
On Wed, Oct 25, 2023 at 05:18:21AM -0700, Stephanos wrote:
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\///')
% pwd
/home/kt/work/omniview
% git show --oneline
d895316 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #49 from skunkforce/dp/version_info
% git log -1 --pretty=%D | awk '{split($0, a, ", "); print a[1]}' | sed 's/refs\/tags\///'
HEAD -> master
You probably want to use git-describe(1).
Piping awk into sed is generally an anti pattern. Awk can do the
substitution.
# 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?
Can't you just generate the version info during compile time?
|
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:
What should happen in the case, that something is pushed and build in CI without being tagged? |
On Wed, Oct 25, 2023 at 11:03:24PM -0700, Stephanos wrote:
Version triple is only necessary for release build in CI I guess
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.
What should happen in the case, that something is pushed and build in
CI without being tagged?
Use `git describe --long --dirty --tags` to get the tag and put it in
every build. If you need to make a source distribution, make sure there
is a version info in a file which gets updated when creating the
archive.
|
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. |
On Fri, Oct 27, 2023 at 03:59:58AM -0700, Stephanos wrote:
> I disagree here. Version is only necessary.
Version is always necessary is what I wanted to say.
|
Now that we have a release version, this issue should be resolved. @bjoekeldude . |
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:
After running
chmod +x
on the file and adding it to.git/hooks
this should potentially work when runningAny opinions?
The text was updated successfully, but these errors were encountered: