About two weeks ago I migrated a project from CVS to git. After migration when we tried to build the project it kept failing.
On debugging, I figured that in
build.xml (it’s a legacy project with a complex ANT build script) they were trying to figure out from which tag it has been checked out by reading the
Tag file in the
Since this file wasn’t going to be there in the cloned git repo, I started looking ways to achieve this in git. I finally found a git command which gives the tag details of the current checkout, and it’s:
This command gives the details about the most recent tag reachable from it. You can read more about it at https://git-scm.com/docs/git-describe
To use it in ANT all one has to do is create a an executable git target and pass describe as its argument. Below is how we are getting the details:
<target name="tag-details" > <!-- Get the closest tag string using git describe if possible --> <echo message="Getting git tag details"/> <exec executable="git" outputproperty="project.tag.details" failifexecutionfails="false"> <arg value="describe"/> </exec> </target>