Seravo / wordpress

The WordPress project layout used by many of Seravo's customers, suitable also for local development with Vagrant and git deployment
https://seravo.com
GNU General Public License v3.0
104 stars 53 forks source link

Post-receive git hook isn't listing correct files #103

Closed tnottu closed 5 years ago

tnottu commented 5 years ago

What does git hook execution mean? What command shall I run to reproduce it?

Maybe https://github.com/Seravo/wordpress/blob/master/scripts/git-hooks/post-receive#L25 isn't listing correct files. This by the way differs from https://github.com/Seravo/wordpress/blob/master

Originally posted by @ottok in https://github.com/Seravo/wordpress/issues/102#issuecomment-498664612


Line 25 actually loops only the changes made in the last commit. If you push multiple commits at once, the changed files from previous commits are not detected.

This code has worked well for us. Credits to @kosminen.

changed_files=""
while read oldrev newrev refname; do
  if [ "$refname" = "refs/heads/master" ]; then
    changed_files=$(git diff-tree --name-only -r $oldrev $newrev)
  fi
done