Gitolite Configure post-push hook and perform operation on committed content

40 views Asked by At

I am using the Gitolite to create the git repo.

I have requirement that when user push something to repo it must have some specific file (eg. .md file) otherwise don't let push the code.

So now I need to configure a post-push hook and do some operation on pushed content.

Can any one please help me to do the same?

1

There are 1 answers

0
VonC On

First, I would not recommend gitosis (old and obsolete).

Second, this is a job for a VREF (update hooks in Gitolite lingo).
You can use in that VREF a diff --name-only or diff --name-status:

 git diff --name-only <sha-old> <sha-new>

(See shell explained)

If the list doesn't include your .md file, you would exit with a non-zero status, and the git push would be denied.