触发自动删除 EOL 空格?
可以编写一个 perforce 触发器来在提交时自动删除空格吗?最好用Python?那会是什么样子?或者您不能在提交文件时修改它们吗?
Can one write a perforce trigger to automatically remove whitespace at submission time? Preferably in python? What would that look like? Or can you not modify files as they're being submitted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,这是无法完成的,因为您无法将修改后的文件内容放回服务器。唯一允许您查看的两种触发器类型
p4 print
的文件内容是change-content
和change-commit
。对于后者,文件已经提交到服务器上,而对于前者,虽然您可以看到(未提交的)文件内容,但无法修改它并将其放回到服务器上。唯一可能的触发器是拒绝提交带有 EOL 空格的文件,以便提交者可以自行修复文件。以下是检查文件中选项卡的类似内容的摘录,请阅读有关触发器的文档并查看 Perforce 网站的示例:
To my knowledge this cannot be done, since you cannot put the modified file-content back to the server. The only two trigger types that allow you to see the file-content with
p4 print
arechange-content
andchange-commit
. For the latter, the files are already submitted on the server and for the former, while you can see the (unsubmitted) file content, there is no way to modify it and put it back on the server.The only trigger that is possible is to reject files with EOL whitespace to be submitted, so that the submitters can fix the files on their own. Here is an excerpt of a similar one that checks for tabs in files, please read the docu on triggers and look at the Perforce site for examples: