Search code examples
gitgit-tag

How i can filter git log on multiple tags


After I commit to master I run several CI that tag the commit they finished successfully. Say I have two CI - unit tests and integration tests that both create tags on the commit. Say unittest-signoff/{number} and integrationtest-signoff/{number}, where {number} is autoincremental number to assure uniqueness.

if I execute git log -n1 --tags="unittest-signoff" this will give me the most recent commit that is already signed off from unit tests. Same for git log -n1 --tags="integrationtest-signoff"

My question is, what command will give me the most recent commit that has both tags at the same time.


Solution

  • git log lets you choose which decorations to look at, so this should serve:

    git log --no-walk --tags  --pretty=%H\ %d --decorate-refs=refs/tags/*-signoff \
    | grep integrationtest-signoff | grep -m1 unittest-signoff