Skip to content

Instantly share code, notes, and snippets.

@Zeex
Created November 28, 2012 14:58
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 Zeex/4161802 to your computer and use it in GitHub Desktop.
Save Zeex/4161802 to your computer and use it in GitHub Desktop.
Recover Git tags from commit messages
#!/usr/bin/env python3
import subprocess
command = 'git log --oneline | grep "^[0-9a-f]\{1,7\} v[0-9\.]*$"'
output = subprocess.check_output(command, shell=True).decode('utf-8')
for line in output.splitlines():
commit, tag = line.split()
subprocess.call('git tag -a %s -m %s %s' % (tag, tag, commit), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment