Skip to content

Instantly share code, notes, and snippets.

@AndreaCrotti
Created October 14, 2016 16:32
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 AndreaCrotti/f2c01f8ad2fc6db6e7ffe268a7eb72a8 to your computer and use it in GitHub Desktop.
Save AndreaCrotti/f2c01f8ad2fc6db6e7ffe268a7eb72a8 to your computer and use it in GitHub Desktop.
def get_last_tag(repo):
"""Return last tag object ordering by date of the commit
"""
try:
return sorted(repo.tags, key=lambda t: t.commit.authored_date, reverse=True)[0]
except IndexError:
raise NoTags("There are no tags in this repository, add a first valid one with `git tag 0.0.1`")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment