#!/bin/bash
# Usage: list_taghistory <project>
#
# Note: the same can be achieved by checking out the <project>-cmake repository
# and running 'git log' with any desired options in it.
#
# This is here mostly because such a command existed before.
#

GITROOT=${GITROOT:=https://gitlab.cern.ch/atlas-tdaq-software}

if [ $# -eq 0 ]; then
    echo "Usage: $0 <project>"
    echo "    where <project> is a valid versioned project name, e.g. tdaq-06-02-00"
    exit 1
fi

release="$1"
shift

case $release in
    tdaq-common-*)
	project=tdaq-common-cmake
	;;
    dqm-common-*)
        project=dqm-common-cmake
	;;
    *)
        project=tdaq-cmake
        ;;
esac

case ${release} in
    *-nightly)
        branch=$(echo ${release} | sed 's;nightly;99-00-00;')
        ;;
    *-dev)
        branch=$(echo ${release} | sed 's;dev;99-00-01;')
        ;;
    nightly)
        branch=tdaq-99-00-00
        ;;
    dev)
        branch=tdaq-99-00-01
        ;;
    *)
        branch=${release}
        ;;
esac

tc=$(mktemp -d)
trap "rm -rf ${tc}" EXIT
cd ${tc}

git clone -n -q ${GITROOT}/${project}.git || exit 1
cd ${project} || exit 2
git checkout -q ${branch} || exit 3
git log --format="%an: %s"

