github-linguist包括语言统计中带有linguist-vendor属性的文件



我有一个github存储库,它主要是c++,但有许多供应商生成的C代码(微控制器的驱动程序),这些代码完全脱离了语言统计。我已经阅读了这一页,并在我的存储库中创建了一个.gitattributes文件,该文件应该将所有这些驱动程序文件标记为linguist-vendored,并防止它们被包含在统计数据中。虽然git check-attr报告设置了linguist-vendored属性,但github-linguist命令行工具仍然忽略了这一点。我做错了什么?

$ cat .gitattributes
STM32[[:space:]]Code/*/** linguist-vendored
STM32[[:space:]]Code/*/Core/Src/** -linguist-vendored
STM32[[:space:]]Code/*/Core/Inc/** -linguist-vendored
$ git add .gitattributes
$ git commit --amend --no-edit
[master 017861e] fix github language metrics
Date: Sat Sep 25 16:09:00 2021 -0700
1 file changed, 3 insertions(+)
create mode 100644 .gitattributes
$ git check-attr -a "STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c"
STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c: linguist-vendored: set
$ github-linguist --breakdown
94.75%  C
2.92%   C++
2.09%   Makefile
0.23%   Assembly
0.01%   Shell
...
C:
STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c
...

我也试过将.gitattributes文件更改为

STM32[[:space:]]Code/** linguist-vendored

,它仍然不会忽略里面的文件。

我怀疑你可能使用的是旧版本的Linguist和/或rugged(这就是检查git属性的方法);可能是您的操作系统附带的版本,因为我无法使用GitHub使用的最新版本重现您的行为:

$ gem install github-linguist
Fetching github-linguist-7.16.1.gem
Building native extensions. This could take a while...
Successfully installed github-linguist-7.16.1
1 gem installed
$ git init foo
Initialized empty Git repository in /Users/lildude/Downloads/trash/foo/.git/
$ mkdir -p "foo/STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/"
$ echo "foo" > "foo/STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c"
$ cd foo
$ git add .
$ git commit -m 'Initial commit'
$ github-linguist . --breakdown
100.00% 4          C
C:
STM32 Code/BLDC/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c
$ echo "STM32[[:space:]]Code/*/** linguist-vendored" > .gitattributes
$ git add .gitattributes
$ git commit -m 'overwrite'
[main 15e0a4e] overwrite
1 file changed, 1 insertion(+)
create mode 100644 .gitattributes
$ github-linguist . --breakdown

$

最新更新