github-linguist 在语言统计中包含具有 linguist-vendored 属性的文件
github-linguist including files with linguist-vendored attribute in language statistics
我有一个 github 存储库,它主要是 C++,但有很多供应商生成的 C 代码(微控制器的驱动程序),完全不符合语言统计数据。我已阅读 this page 并在我的存储库中创建了一个 .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 and/or rugged(检查 git 属性的功能);可能是你的 OS 附带的版本,因为我无法使用 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
$
我有一个 github 存储库,它主要是 C++,但有很多供应商生成的 C 代码(微控制器的驱动程序),完全不符合语言统计数据。我已阅读 this page 并在我的存储库中创建了一个 .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 and/or rugged(检查 git 属性的功能);可能是你的 OS 附带的版本,因为我无法使用 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
$