Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mercurial 有没有一种简单的方法可以确保我的项目中的所有文件都存在许可证阻止?_Mercurial_Licensing - Fatal编程技术网

Mercurial 有没有一种简单的方法可以确保我的项目中的所有文件都存在许可证阻止?

Mercurial 有没有一种简单的方法可以确保我的项目中的所有文件都存在许可证阻止?,mercurial,licensing,Mercurial,Licensing,我需要一个许可证: // Copyright Billy O'Neal 2010 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //版权所有比利·奥尼尔2010 //根据Boost软件许可证1

我需要一个许可证:

// Copyright Billy O'Neal 2010 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //版权所有比利·奥尼尔2010 //根据Boost软件许可证1.0版发布。 //(参见随附的文件LICENSE_1_0.txt或副本,网址为 // http://www.boost.org/LICENSE_1_0.txt) 嵌入到我的所有源文件中。我担心我可能丢失了一个或多个这些文件,我不想在没有这些文件的情况下将源代码发布到我的库中。有没有一种简单的方法可以查看一个项目并转储所有没有此类块的文件

将此连接到Mercurial的方法的额外好处是,如果存在缺少许可证的文件,提交将无法成功


(我有很多工具可以找到块,但没有工具可以找到丢失的块)

基本上,您需要组合:

  • ,它“对给定文本进行不区分大小写的搜索”(请参见“”):实际上,它将搜索提交消息,而不是所有文件内容。
    通过任何脚本(如)都可以更好地搜索文件
    例如,注释中建议(对于Unix环境):
查找$(hg root)-键入f-name'*.cpp'| xargs grep--没有匹配许可证的文件
  • (注意,“precommit钩子将在执行了从repo中自动添加/删除文件后运行,这不是您想要的:请参见“”)。
    注意:如果您只需要在许可证消息不存在时阻止提交,但不介意向即将提交的变更集中添加/删除文件,那么预提交就可以了

我认为
--keyword
检查的是提交消息,而不是文件。@Ry4an:这就是为什么我在你发表评论时准确地编辑了我的答案;)(及其评论)详细说明了“
hg log-k
命令。你可能可以在这样的检查中进行答案交换:
find$(hg root)-键入f-name'*.cpp'| xargs grep--没有匹配许可证的文件_1_0.txtunix@Ry4an当前位置关于“
hg root
”部分的观点很好:我已将你的建议包括在答案中。嘿,它以相当大的优势击败了所有其他人。 find $(hg root) -type f -name '*.cpp' | xargs grep --files-without-match LICENSE_1_0.txt