#!/bin/sh

set -eu

if [ $# -lt 2 ]; then
   echo "Usage: $0 <tag> <path>"
fi

expected_tag="$1"
working_dir="$2"

cd "${working_dir}"
current_tags=$(git tag --points-at HEAD)
if ! echo "${current_tags}" | grep -qe "^${expected_tag}\$"; then
   echo "Current tags '$(echo "${current_tags}" | xargs)' != expected tag '${expected_tag}' in cloned repo '${working_dir}'"
   exit 1
fi

Add script to check tags of a given git repo
Add script to check tags of a given git repo

This script can be used to check that the expected tagged version of
boshrelease is checked out before pushing.

We will use this feature to workaround the limitations on the
concourse git-resource when using tag filters: Regardless the tag-filter
the versions previously reported by the git-resource are still vaid
versions, so concourse might checkout the wrong version if no newer
version has been reported.
