Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#1,691 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.)

Lingua principale
TypeScript
Stelle
3.9k
Fork
374
Merge medio
20h 5m
PR unite (30g)
38

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sourcebot-dev/sourcebot

Tutte le issue di sourcebot-dev/sourcebot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.