Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[bug] .gitattributes linguist-language overrides are ignored for files in subdirectories

Aberta
#1,691 0 comentários 0 reações 0 responsáveis Ver no GitHub

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
  1. In an indexed repo, add *.h linguist-language=C to .gitattributes and have a header in a subdirectory, e.g. src/foo.h.
  2. Open src/foo.h in 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

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sourcebot-dev/sourcebot

Todas as issues de sourcebot-dev/sourcebot

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.