Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get current tag of branch and increment patch version
import git
git_path = '/path/to/git_dir/'
repo = git.Repo(git_path)
cur_version = repo.git.describe()
major, minor, patch = cur_version.split('.')
updated_patch = int(patch)+1
new_tag = '.'.join((major, minor, str(updated_patch)))
print(new_tag)
@gnilchee

This comment has been minimized.

Copy link
Owner Author

gnilchee commented Jan 21, 2018

~/git_dir# git describe --tags
v3.1.4567
root@2ed8ca477170:~# python git_describe_tags.py
v3.1.4568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.