#!/usr/bin/env bash

EXPECTED_HASH="379029235e57e4b1f9d8482fa01cc4c6a103c58ea9035cc0dd7e6f020a199efb"
FILE_PATH="django/contrib/admin/static/admin/css/base.css"

cd django
# Iterate over all tags
for tag in $(git tag --sort=v:refname); do
  echo -n "Checking $tag... "
  
  # Check if file exists at this tag
  if git ls-tree -r "$tag" --name-only | grep -qx "$FILE_PATH"; then
    # Extract file contents at tag and compute sha256
    HASH=$(git show "$tag:$FILE_PATH" | sha256sum | awk '{print $1}')
    if [[ "$HASH" == "$EXPECTED_HASH" ]]; then
      echo "MATCH"
    else
      echo "no match"
    fi
  else
    echo "file not present"
  fi
done
cd ..
