I need a way to print git tag info selectively.
Firstly I choose git for-each-ref to print all tag info:
git for-each-ref --format="%(refname:short)" refs/tags/
It's output looks like:
proj1_v1.0.0
content
proj1_v1.0.1
content
proj2_v1.0.0
content
It's right, but I want to print the message which only contains "proj1".
After I find the solution in git dev guide(https://git-scm.com/docs/git-for-each-ref)
Used as %(if)…?%(then)…?%(end) or %(if)…?%(then)…?%(else)…?%(end). If there is an atom with value or string literal after the %(if) then everything after the %(then) is printed, else if the %(else) atom is used, then everything after %(else) is printed. We ignore space when evaluating the string before %(then), this is useful when we use the %(HEAD) atom which prints either "*" or " " and we want to apply the if condition only on the HEAD ref. Append ":equals=" or ":notequals=" to compare the value between the %(if:…?) and %(then) atoms with the given string.
I change my script to
git for-each-ref --format="%(if) %(refname:equals=proj1*)%(refname:short) %(end)" refs/tags/
But it raise error:
fatal: unrecognized %(refname:equals=hi) argument: equals=hi
Do I have a misleading on this sequence?
Append :equals=<string>
or :notequals=<string>
to compare the value between the %(if:…?)
and %(then)
atoms with the given string
question from:
https://stackoverflow.com/questions/65641647/how-to-print-git-tag-info-selectively 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…