#!/bin/bash
changedFiles="$(git diff-tree --no-commit-id --name-only -r ${ghprbActualCommit})"
echo changedFiles
IFS=$'\n' read -rd '' -a y <<<"$changedFiles"

pwd=$(pwd)
n=0
for i in "${y[@]}"
do
    IFS='//' read -r targetDb changelog type <<< "$i"
    #
    # TODO: check to see if the targetDbs between PRs
    #       are the same, if not, fail.
    #
    #fi targetDb !=prev targetDb DIE
    #
    # TODO: check to see that dml is executed before ddl
    #       or come up with some way to define dependencies
    #
    #fi type ='dml' exec after ddl
    #
    outFile='liquibaseBuild'$((n++))'.properties'
    echo -n 'changeLogFile='"$(pwd)"'/'"$i" > "$outFile"
    echo $'\ntargetDb='"$targetDb" >> "$outFile"
    cat "$outFile"
done