0

I would like to take the contents of each file pushed to a git repo, and store the file contents in MySQL. A quick google and read says I need to hook into git using a post-commit hook. However, what does the actual post-commit hook look like to loop through each file in the commit?

Is there a pre-built library for doing this? Prefer PHP, Node.js, or pure Bash.

Thanks.

Justin
  • 42,716
  • 77
  • 201
  • 296

1 Answers1

0

you don't need a hook if you just do a cron job to poll for any changes and then iterate through the new objects via git ls-tree and git show.

You can also get a local script to be triggered by github hooks (they just trigger the script and you can only customize endpoints).

You can use client side hooks as some have alluded to in the comments. But you need something on the side of where commits are going to be pushed to, so that implies server side hooks.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • Adam, I need a post-receive hook. I must process changes as they are pushed to the server, not on a cron scheduler. – Justin May 14 '13 at 06:10
  • If you're pushing to github, you can't run arbitrary code on their servers. They have standard hooks that can call out to something that you can set up on your servers to do what you want. – Adam Dymitruk May 14 '13 at 22:06