Friday, May 1, 2020

Script to check if changes have happened under a particular directory

api=("src/api-engine/"
     "build_image/docker/common/api-engine")
dashboard=("src/dashboard/"
     "build_image/docker/common/dashboard")
ansibleagent=("src/agent/ansible/"
     "build_image/docker/agent/ansible")

allcomps=("api" "dashboard" "ansibleagent")
declare -A OPS

cdir=$(pwd)
cd ~/hl/src/github.com/realcello
allchanges=$(git diff --name-only HEAD~1 HEAD~10)
cd $cdir

echo "$allchanges"

for value in ${allcomps[@]}; do
  comps="${value}[@]"
  echo 'Items in '${value}
  for item in "${!comps}"; do
    echo "   checking $item"
    if echo "${allchanges}" | grep -q "$item"
    then
      OPS["${value}"]='true'
    fi
  done
done

for item in "${allcomps[@]}"; do
  echo "$item"="${OPS[$item]}"
done

No comments:

Post a Comment