git tag - How do I read tagger information from a git tag? -
so far have:
git rev-parse <tagname> | xargs git cat-file -p
but isn't easiest thing parse. hoping similar git-log
's --pretty
option grab info need.
any ideas? thanks
a more direct way of getting same info is:
git cat-file tag <tagname>
this uses single command , avoids pipe.
i used in bash script follows:
if git rev-parse $tag^{tag} -- &>/dev/null # annotated tag commit=$(git rev-parse $tag^{commit}) tagger=($(git cat-file tag $tag | grep '^tagger')) n=${#tagger} # number of fields date=${tagger[@]:$n-2:2} # last 2 fields author=${tagger[@]:1:$n-3} # first , last 2 message=$(git cat-file tag $tag | tail -n+6) elif git rev-parse refs/tags/$tag -- &>/dev/null # lightweight tag - commit, commit=$(git rev-parse $tag^{commit}) else echo "$tag: not tag" >&2 fi
Comments
Post a Comment