.gitattributes 语言学家属性标准

.gitattributes linguist attributes standard

我刚刚创建了一个新的 Laravel 项目,并且正在设置我的 .gitattributes Linguist 属性。问题是,我不确定要为哪个 files/directories.

设置哪些

默认 .gitattributes 文件如下所示:

* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

首先,为什么所有.css.scss.js文件都设置为linguist-vendored?这不仅会从 Linguist 中排除所有此类用户创建的文件,而且 Laravel 也分别只有 1、2 和 4 个这些文件,这将如何显着影响 Linguist 统计数据?

其次,有没有关于哪些文件应该被标记为linguist-vendored的convention/standard?我应该标记所有 Laravel 文件,只标记我不修改的文件,只标记 vendor 目录,还是根本 none?或者甚至是其他东西?

提前致谢!

First of all, why are all .css, .scss and .js files set to linguist-vendored?

根据我对提交 e3630a5 and 93876d6 阅读评论的理解,作者希望确保 Laravel 项目被标记为 PHP(GitHub 用语言统计中的第一语言标记项目。

Not only would this exclude all such user-created files from Linguist, but Laravel also only has respectively 1, 2 and 4 of these files, how would this significantly impact Linguist stats?

在 Linguist 中,语言统计数据来自每种语言的文件大小(您可以阅读我在 how Linguist works 上的回答以了解更多详细信息)。因此,单个大文件可以更改语言统计信息

在 Laravel 的情况下,如果我在存储库中删除 Linguist 覆盖并再次 运行 Linguist,我会得到以下统计信息:

94.11%  PHP
3.30%   HTML
1.42%   JavaScript
0.68%   Vue
0.49%   CSS

因此无需使用 Linguist 覆盖将存储库标记为 PHP。不过,添加覆盖后可能会有更大的文件。

请注意,Laravel 存储库包含两个大的缩小文件。 Linguist 识别出有 minified 并将它们标记为已生成,从而自动将它们排除在统计之外。

Secondly, is there any convention/standard regarding which files should be marked as linguist-vendored? Should I mark all Laravel files, only the ones that I don't modify, only the vendor directory, or none at all? Or maybe even something else?

这真的取决于你;据我所知,没有关于什么构成销售代码的约定

在 Linguist 中,we try to mark as vendored 所有可能影响统计数据但并非由存储库所有者编写的第三方代码。不过,您可以使用覆盖更改默认行为。