简体   繁体   English

使用post commit钩子将Git提交到MySQL

[英]Git commit to MySQL using a post commit hook

I would like to take the contents of each file pushed to a git repo, and store the file contents in MySQL. 我想将每个文件的内容推送到git repo,并将文件内容存储在MySQL中。 A quick google and read says I need to hook into git using a post-commit hook. 一个快速的谷歌阅读说我需要使用提交后的钩子钩入git。 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. 建议使用PHP,Node.js或纯Bash。

Thanks. 谢谢。

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 . 如果您只是执行cron工作以轮询任何更改,然后通过git ls-treegit 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). 您还可以获取由github钩子触发的本地脚本(它们仅触发脚本,并且您只能自定义端点)。

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. 但是您需要在提交将被推送到的那一侧进行操作,因此这意味着服务器端挂钩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM