Search code examples
gitjavadocgit-tag

Get next release tag for each file in Git repository


I need to assign @since Javadoc tag to every class in my repository.

This information can be retrieved by looking for creation date of each file and then looking for the next tag that was made in repository.

Are there any Git commands to help me with the above?


Solution

  • You would need to do a pickaxe search git log -S<className>|tail -1 in order to get the first git commit where className was added to the repo (as className.java).

    Then you could use git describe with git describe --contains <commit>:

    Instead of finding the tag that predates the commit, find the tag that comes after the commit, and thus contains it.
    Automatically implies --tags.