想要设置一个将提交的文件复制到特定文件夹的挂钩 [英] Want to setup a hook that copies committed files to a particular folder
问题描述
背景:使用 PHP Laravel 框架和开发 Facebook 应用程序用于数据库的 MySQL.
Background: Developing a Facebook app using PHP Laravel framework & MySQL for database.
我已经在我们的开发服务器上设置了 Gitlab,并在其上创建了一个存储库,团队已添加并正在提交 &推送代码.
I have setup Gitlab on our development server and created a repository on it where the team has been added and is committing & pushing code.
我想做的是,当我将代码推送到 GitLab 上的特定分支(例如 Master)时,我希望它可以在/var/www/productname 上使用,以便我可以在 Facebook 画布中对其进行测试以及(某些无法在本地机器上测试的事情发生在那里).
What I would like to do is, when I push code to a particular branch on GitLab (for example Master) I would like it to be available at /var/www/productname so that I can test it within the Facebook canvas as well (certain things happen there that can't be tested on your local machine).
但是,我不希望每次在 master 上发生推送时,钩子都会复制所有文件,而只复制被修改的文件.
However, I don't want the hook to copy all the files over every time a push happens on master, just the files that were modified.
有人可以帮忙解决这个问题吗?
Can anyone help out with such a hook?
谢谢.
推荐答案
此操作使用 rsync 而不是 cp.它会自动进行差异检查.这样你的 post-commit 钩子就不会变得不必要的复杂.
Use rsync rather than cp for this operation. It does diff checking automatically. that way your post-commit hook doesn't become needlessly complicated.
这篇关于想要设置一个将提交的文件复制到特定文件夹的挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!