Skip to content

Instantly share code, notes, and snippets.

@da-h
Last active October 5, 2019 06:42
Show Gist options
  • Save da-h/725db81cc9bc333e8c5c80459ddd4966 to your computer and use it in GitHub Desktop.
Save da-h/725db81cc9bc333e8c5c80459ddd4966 to your computer and use it in GitHub Desktop.
annotate git commits by their corresponding version
#/bin/bash
branch=master
versionfile=src/module/__init__.py
for commit in $(git rev-list $branch --reverse)
do
version=$(git show $commit:$versionfile | sed -n -e "s/^__version__ = \"\([0-9]\+\(\.[0-9]\)\+\)\"/\1/p")
echo $version
git tag -a v$version $commit -m "Release, v$version"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment