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 54 forks source link

Git pre commit hook should test only the committed files and not all of head #4

Closed onnimonni closed 9 years ago

onnimonni commented 9 years ago

When I run git commit file.php -m "message" the pre-commit hook tests the state containing all latest files in directory. It should only test head + files_to_be_committed so there won't be any mismatch with the tests and commits.

anttiviljami commented 9 years ago

One solution would be that we do a trial commit where we clean up everything and test before the actual commit:

e.g.

git commit -n "pre-commit temporary commit" # create a test commit 
git stash # gets rid of all unstaged changes
{ run tests } 
git reset HEAD~1 # drop the temporary commit
git stash apply # pull back unstaged changes 
{ exit with the code from { run tests } and proceed with commit }

I'm just not sure if committing inside a pre-commit script is even possible.

onnimonni commented 9 years ago

Well we can use The git commit -n flag so ofc it is possible. This just seems really hacky :O

Onni Hakala 0445158280 onni@koodimonni.fi Koodimonni TMI

On Thu, Mar 19, 2015 at 4:53 PM, Antti Kuosmanen notifications@github.com wrote:

One solution would be that we do a trial commit where clean up everything before the actual commit: e.g.

git commit -n "pre-commit temporary commit" # create a test commit 
git stash # gets rid of all unstaged changes
{run tests} 
git reset HEAD~1 # drop the temporary commit
git stash apply # pull back unstaged changes 

I'm just not sure if committing inside a pre-commit script is even possible.

Reply to this email directly or view it on GitHub: https://github.com/Seravo/wordpress/issues/4#issuecomment-83614896