I want to only run a piece of bash code if a git tag exists for the current commit.
The command git describe --exact-match
gives throws an error if there is no git tag for the current commit which is a good start so I'm trying to combine that into an if statement in bash:
if $(git describe --exact-match); then
TAG="$(git describe --exact-match)"
echo "TAG=$TAG"
else
echo "no tag"
fi
The above code works when there is no tag for the current commit but if there is a tag then it fails.