Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Parsing git tags to versions

Joined
Aug 14, 2009
Messages
2,304
Reaction score
1,189
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


Base functions for outputting schematic versions:


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.1

return of GetChangelist contains this: ac55b7
return of GetBranch contains this: master
return of GetVersion contains this: [4, 6, 1]

And this is the final file with tpl replacements:


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:
{changelist}
{formatVersion}
{buildVersion}
{commentVersion}
{shortVersion}
{visibility}
{branch}

Example output:
ac55b7
4,6,1
461
4 6 1
4.6
PUBLIC
Releases

Example tags:
oarkfl0 - Parsing git tags to versions - RaGEZONE Forums


Example branches (master always has a visibility of public):
oXTiidx - Parsing git tags to versions - RaGEZONE Forums


Example usage:
- Doxyfile (Doxygen config) auto adjustment of the version
- Header file for CPP to auto-correct the version number

Example cmd line:
Code:
gitVerToHeader.py F:\GitRepos\TestRepository\ F:\GitRepos\TestRepository\Docs\doxygen_conf

Note:
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


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.
 

Attachments

You must be registered for see attachments list
Last edited:
  • Like
Reactions: DNC
Back
Top