So lately I was searching for something that could parse git tags into version numbers. I wasn't quite happy with what I found, so I started to create my own Python script for that.
Note:
The changelist is the first 6 characters of the sha hash.
This script requires Parse
Base functions for outputting schematic versions:
https://gist.github.com/exmex/06229ec035cd8949e6e2
Output is like this:
[DEBUG]: Getting changelist from git...
[DEBUG]: Got changelist ac55b7
[DEBUG]: Getting branch from git...
[DEBUG]: Got branch master
[DEBUG]: Getting versionlist from git...
[DEBUG]: Got versionlist 4.6.1And this is the final file with tpl replacements:return of GetChangelist contains this: ac55b7
return of GetBranch contains this: master
return of GetVersion contains this: [4, 6, 1]
https://gist.github.com/exmex/3d8d9cfadc998d52dd67
With this you've to specify the cwd (Current working directory) as the first argument. The cwd is basically the root of the git repository. Also the git path is on both versions in a variable. So you don't have to have git in the PATH variable.
It's only called "Schematic Versioning to CPP Header" it can be used to generate all sorts of files. Because it replaces stuff in the template file.
Example tpl file:
Example output:{changelist}
{formatVersion}
{buildVersion}
{commentVersion}
{shortVersion}
{visibility}
{branch}
Example tags:ac55b7
4,6,1
461
4 6 1
4.6
PUBLIC
Releases
Example branches (master always has a visibility of public):
Example usage:
- Doxyfile (Doxygen config) auto adjustment of the version
- Header file for CPP to auto-correct the version number
Example cmd line:
Note:Code:gitVerToHeader.py F:\GitRepos\TestRepository\ F:\GitRepos\TestRepository\Docs\doxygen_conf
This was ONLY tested on windows. I cannot guarantee that it will work with linux. Because my development environment is using windows!
This script requires Parse
Code is published under MIT license.
The MIT License (MIT)
Copyright (c) 2016 GigaToni
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.





Reply With Quote

