Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Last active January 21, 2018 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnilchee/d596b4708b5aaa342d3c9dd1ab6b69f0 to your computer and use it in GitHub Desktop.
Save gnilchee/d596b4708b5aaa342d3c9dd1ab6b69f0 to your computer and use it in GitHub Desktop.
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
Copy link
Author

~/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