我有一个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而且它仍然不会忽略里面的文件。
发布于 2021-09-27 08:42:09
我怀疑你使用的可能是旧版本的Linguist和/或rugged (这是用来检查gitattributes的);可能是你的操作系统附带的版本,因为我不能用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
$https://stackoverflow.com/questions/69330846
复制相似问题