Reputation: 5058
I seem to remember seeing in one other revision management system that you could put a complicated magic string in your code and the revision management system would automatically replace that pattern by a version string. The point is that I would like an about dialog box in my application which displays the current version. In everything I have seen about Git, it does not change a single bit of your sources. Another idea is that git creates a single text file that the sources can read to display the version. I don't like the idea of having to call Git and copying the tag by hand into my code.
Upvotes: 1
Views: 131
Reputation: 133
I simply ask the OS/Git for the tag info. This is my version view (php):
<?php
$output = [];
exec("git tag", $output);
$version = end($output);
?>
{{$version}}
That way i only store the version in one place.
Upvotes: 0
Reputation: 1326776
You can setup a post-commit hook calling a python script like manuelbua/gitver
(from Manuel Bua, also on Stack Overflow).
Goal:
I want the version string and/or other useful information to be embedded in the application code automatically, "compiled-in" so to speak, without me having to remember to do it manually each time.
Workflow:
- you are working on your repository, now you are ready to promote the current version to the next release
- create a release tag,
git tag -a v0.0.2 -m 'Bump version'
- defines your
NEXT
version, the one you are going to work towards to by runninggitver next 0.0.3
- run
gitver
and check everything is fine- OPTIONAL: preview or update your project's version information templates by running
gitver preview <template name>
orgitver update <template name>
, then rebuild the project to reflect version changes- any other manual house-keeping in-between releases can be performed now
- now you are working towards the NEXT release, repeat when release time has came again
That helps you generate a file with the right metadata information (like the version derived from the app last tag), for you to use during the build.
Upvotes: 1
Reputation: 97285
In everything I have seen about Git, it does not change a single bit of your sources
Wrong. It can and it do it - "text normalization" for cross-platform usage is big git's headache
The point is that I would like an about dialog box in my application which displays the current version.
Under the hood it's almost always git describe
output, which command (on build stage) you can use on your working dir, store and use later
Another implementation is "smudge|clean filters": keyword, stored as static text in repository, converted to dynamically changing element in working directory (really - related to filters programs perform this bidirectional transformation)
Upvotes: 1