#!/bin/sh

# retrieve the name of the image that was modified in the latest commit
# this script should become obsolete as soon as a proper way of getting the modified files is added to Gitlab CI

RES=""
for i in $(git diff-tree --no-commit-id --name-only $CI_COMMIT_SHA)
do
	case "$i" in
		*pica*) RES=$i ;;
	esac
done
RES=$(cat $RES/docker-compose.yml | grep image: | head -n1 | cut -d ':' -f2-)
if [[ "$RES" == "" ]]
then
	exit 1
else
	echo $RES
fi