[bug] .gitattributes linguist-language overrides are ignored for files in subdirectories
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- tooling
Direção de pesquisa
Start in packages/web/src/lib/gitattributes.ts at resolveLanguageFromGitAttributes and review the existing unit test mentioned in the report. Run the test, then verify that filename-only patterns match files in subdirectories and slash-containing patterns are matched from the repository root, including leading-slash anchors.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
linguist-language overrides in .gitattributes only apply to files at the repository root. resolveLanguageFromGitAttributes in packages/web/src/lib/gitattributes.ts passes the full repo-relative path to micromatch.isMatch(path, pattern). So *.h linguist-language=C does not match src/foo.h, and an anchored pattern like /config.in never matches at all.
Git's rule: a pattern without a slash matches the file name in any directory; a pattern with a slash is matched from the repo root (a leading / just anchors it).
To reproduce
- In an indexed repo, add
*.h linguist-language=Cto.gitattributesand have a header in a subdirectory, e.g.src/foo.h. - Open
src/foo.hin the file viewer. The override is ignored and the default language is used.
Or in code: resolveLanguageFromGitAttributes('src/foo.h', parseGitAttributes('*.h linguist-language=C')) returns undefined.
Sourcebot deployment information
Sourcebot version (e.g. v3.0.1): main @ b4931510 (found reading the source and confirmed with a unit test, not on a deployment)
Additional information
I have a small fix with tests ready and will open a PR that links this issue. (Found by an AI coding agent working for the breken-ai account.)
- Linguagem predominante
- TypeScript
- Estrelas
- 3.9k
- Forks
- 374
- Merge médio
- 20h 5min
- PRs com merge (30d)
- 38
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sourcebot-dev/sourcebot
-
bug triage needed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
sourcebot-dev/sourcebot#1681 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
sourcebot-dev/sourcebot#1633 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
sourcebot-dev/sourcebot#1384 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
ask_sb bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
sourcebot-dev/sourcebot#1137 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
sourcebot-dev/sourcebot#1689 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de sourcebot-dev/sourcebot
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/vscode-livepreview#876 ·
Mantenedores costumam responder em até 1 dia
-
needs-triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
JustJarethB/invoicer#54 ·
-
ICP 1.2.0 shows a scheduled task's interval in milliseconds under the label "Interval (In seconds)"AbertaNeeds Triage Type/Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
wso2/product-integrator#2585 ·
Mantenedores costumam responder em até 1 dia
-
Add: Telemundo West sdAbertacheck:passed streams:add
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
design
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
MTES-MCT/monitor-field#119 ·
Mantenedores costumam responder em até 1 dia