#!/bin/sh -e
#
# ---
# source: https://github.com/dandavison/tools

commit="$1"
prevtag=""

for tag in $(git tag --sort=creatordate); do
  if git merge-base --is-ancestor "${commit}" "${tag}"; then
    if [ -z "${prevtag}" ] || ! git merge-base --is-ancestor "${commit}" "${prevtag}"; then
      echo "${tag}"
    fi
  fi
  prevtag=${tag}
done
