在 Perforce 上提交后脚本可以自动化吗?
我们在工作中使用 Perforce,并定期将软件项目保存在存储库中。一般来说,创建者遵循正常的 Perforce 流程,但我们也有一类用户,他们不需要编辑文件,而只需要读取它们。目前我们使用 P4Web,但这需要用户单独下载每个文件来重新组装项目目录。理想情况下,我希望有一个过程,当用户在 Perforce 中进行提交/提交时,脚本会自动运行以生成项目目录和文件的单个 zip 文件,这样就可以保证一键下载与源文件的当前状态保持一致。我知道 Git 有一个提交后钩子可以用于此目的,但我无法在 Perforce 中找到等效的函数。
We use Perforce at work, and routinely keep software projects in the repository. In general creators follow the normal Perforce flow, BUT we also have a class of users, who doesn't have any need to edit the files but only read them. Currently we use P4Web but that requires the user so download each file individually to reassemble the project directory. Ideally I would like to have a process where when a user does a commit/submit in Perforce, the script would automatically run to generate a single zip file of the project directory and files, so that it was a one-click download that was guaranteed to be correct against current state of the source files. I know Git has a post-commit hook which could be used for this, but I can't figure out an equivalent function in Perforce.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短回答:是的,请阅读文档,第 103 页。
这里是 Perforce 提供的所有文档的链接。
答案很长,您可以通过从命令行输入
p4 triggers
来编辑触发器。您提供触发器的名称(即“my_archive”)、触发器的类型(即您的情况下的更改提交)、路径(即 //depot/path/to/the/directory/that/contains/the/ files/to/zip/...)、command_path(您的脚本)以及要传递给脚本的任何变量。真的,看看文档,它真的非常简单而且功能强大。
Short answer: Yes, read the documentation, page 103.
Here is a link to all of the documentation available from Perforce.
Long answer, you can edit the triggers by typing
p4 triggers
from the command line. You provide the name of the trigger (i.e. "my_archive"), the type of trigger (i.e. change-commit in your case), path (i.e. the //depot/path/to/the/directory/that/contains/the/files/to/zip/...), and the command_path (your script), plus any variables to pass along to your script.Really, take a look at the docs, it is really quite simple and powerful.
如果他们只需要读取访问权限,则只需在 p4protect 表中授予他们读取访问权限即可。这样您就可以避免弄乱存储库的快照。
If they just need read access, then just give them read access in the p4protect table. That way you avoid having to mess around with snapshots of your repository.