[bug] .gitattributes linguist-language overrides are ignored for files in subdirectories
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
- 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.)
- Lingua principale
- TypeScript
- Stelle
- 3.9k
- Fork
- 374
- Merge medio
- 20h 5m
- PR unite (30g)
- 38
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sourcebot-dev/sourcebot
-
bug triage needed
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sourcebot-dev/sourcebot#1681 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sourcebot-dev/sourcebot#1633 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
sourcebot-dev/sourcebot#1384 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ask_sb bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
sourcebot-dev/sourcebot#1137 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
sourcebot-dev/sourcebot#1689 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sourcebot-dev/sourcebot
Issue simili
-
priority: P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
prime-radiant-inc/evener#3291 ·
I maintainer di solito rispondono entro 1 giorno
-
accessibility bug revealjs
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
quarto-dev/quarto-cli#14961 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
supabase/agent-skills#614 ·
-
Content
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
RunestoneInteractive/rs#1559 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni