Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git match tag with multiple words

Tags:

git

regex

grep

We can get the last git tag, which starts by a word(e.g TEST) as follow:

git describe --tag --dirty --match 'TEST*'

I am wondering how can I get the last tag, which starts by word1 or word2 (e.g. TEST OR RUN)? I've tried to use regex or following but it does not work:

git describe --tag --dirty --match 'TEST*|RUN*'

SOLUTION: We can get number of commits to HEAD and compare those numbers, the one which has less commits is the more recently. You can find its script in the answer, which I have added.

like image 537
csuo Avatar asked Jun 26 '26 23:06

csuo


1 Answers

The pattern is matched using fnmatch(), which uses shell wildcard patterns, not regular expressions.

As shell wildcards don't support alternation you can't do this without changing the implementation of describe.

Source: git describe source :P

like image 162
Hasturkun Avatar answered Jun 28 '26 18:06

Hasturkun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!