颠覆后提交挂钩
我遇到了一种情况,我正在考虑使用 subversion/svn 作为项目的存储库/版本控制系统。我试图弄清楚是否有可能(如果是的话,如何)能够在提交后挂钩/进程上拥有颠覆系统,以将用户/文件/时间(也许还有消息)写入其中之一外部文件 (csv) 或 mysql 数据库。
一旦我弄清楚如何调用提交后挂钩将输出写入文件,我就可以修改我的问题跟踪器/项目应用程序,然后根据用户角色以及成功/失败来实现基本工作流程存储库文件。
简短的示例/指针会很有帮助。
我的测试环境正在 centos5 上运行 subversion/svnserve。使用的脚本语言是 Php/Python。
I've got a situation where I'm contemplating using subversion/svn as the repository/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook/process to to write the user/file/time (and maybe msg) to either an external file (csv) or to a mysql db.
Once I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker/project app to then implement a basic workflow process based on the user role, as well as the success/failure of the repository files.
Short sample/pointers would be helpful.
My test env, is running subversion/svnserve on centos5. The scripting languages in use are Php/Python.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说这是可能的,但是您将需要一些工作来检索用户名、日期和提交消息。
Subversion 使用存储库路径和刚刚提交的修订版本号作为参数来调用提交后挂钩。
为了检索您要查找的信息,您需要使用名为
svnlook
的可执行文件,它与 Subversion 捆绑在一起。请参阅 repo\hooks\post-commit.tmpl 以获得有关如何使用它的相当清晰的说明。
另外,请查看
svnlook help
,它并不难使用。I would say that's possible, but you are going to need a bit of work to retrieve the username, date and commit message.
Subversion invokes the post-commit hook with the repo path and the number of revision which was just committed as arguments.
In order to retrieve the information you're looking for, you will need to use an executable by the name of
svnlook
, which is bundled with Subversion.See repo\hooks\post-commit.tmpl for a rather clear explanation about how to use it
Also, take a look at
svnlook help
, it's not difficult to use.事实上,很有可能,在你的存储库根目录中应该有一个名为 hooks 的文件夹,其中应该有一个名为 post-commit 的文件(如果没有,创建一个),添加你放在那里的任何 bash 代码,它将在每次提交后执行。
请注意,有 2 个变量传递到脚本中 $1 是存储库,$2 是修订号(我认为),您可以使用这两个变量来执行一些 svn 命令/查询,并提取所需的数据,并且用它做任何你想做的事。
Indeed it is very possible, in your repository root there should be a folder named hooks, inside which should be a file named post-commit (if not, create one), add whatever bash code you put there and it will execute after every commit.
Note, there are 2 variables that are passed into the script $1 is the repository, and $2 is the revision number (i think), you can use those two variables to execute some svn commands/queries, and pull out the required data, and do with it whatever your heart desires.