I've got a bare repo on a production server, which is updated (utilising a webhook in Gitlab) whenever a merge request is approved.
The repo is updated like so:
git fetch origin master:master
git --work-tree=/home/prod/git/ --git-dir/=/path/to/bare-repo.git checkout -f
I would like to use the post-checkout hook to verify whether a conda environment file was changed; Content of the hook:
#!/bin/sh
prevHEAD=$1
newHEAD=$2
checkoutType=$3
changed_files="$(git diff-tree -r --name-only --no-commit-id $prevHEAD $newHEAD)"
Unfortunately everytime the checkout is triggered, and I'm not clear on why this happens, prevHEAD and newHEAD variables are always the same. The values themselves differ on every checkout, however, they always match each other.
Assuming this method can't be used, what would be the best way to identify whether a particular file was changed?
Elsewhere I've read to use push-to deploy model. This would require replacing the fetch & checkout commands with a git push instead, and utilising post-receive hook. I'll look into this, but given that the fetch & checkout already work fine, I'd prefer not changing that setup if possible at all.