Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetLanguages never return candidates if single language was not found #207

Closed
bzz opened this issue Mar 15, 2019 · 1 comment
Closed

GetLanguages never return candidates if single language was not found #207

bzz opened this issue Mar 15, 2019 · 1 comment
Labels
Milestone

Comments

@bzz
Copy link
Contributor

bzz commented Mar 15, 2019

GetLanguages accumulate candidates in case of no single match but never return those

As noted in #205 (comment) if that is changed in a naive way that fails tests.

This issue is about investigating and fixing that as well as assessing any possible side-effects of github.com//pull/205

@bzz bzz added the bug label Mar 15, 2019
@bzz bzz added this to the v1.8.0 milestone Mar 15, 2019
look added a commit to look/go-enry that referenced this issue Apr 13, 2021
Prior to this change, GetLanguages collected all candidate languages from each
strategy to pass to the next strategy (without de-duplicating them). Linguist
only uses the previous strategy's candidates for the next strategy. Also, it
would overwrite languages with nil if a strategy returned that, so you could get
into a situation where you go from multiple languages to no language.

See the Ruby code for details: https://github.com/github/linguist/blob/0b23847af5a8a1e09e1547c0c502601b6dc599ff/lib/linguist.rb#L14-L43

This addresses src-d/enry#207 because GetLanguages
should not return all candidates detected, otherwise it would work differently
than Linguist.
look added a commit to look/go-enry that referenced this issue Apr 13, 2021
Prior to this change, GetLanguages collected all candidate languages from each
strategy to pass to the next strategy (without de-duplicating them). Linguist
only uses the previous strategy's candidates for the next strategy. Also, it
would overwrite languages with nil if a strategy returned that, so you could get
into a situation where you go from multiple languages to no language.

See the Ruby code for details: https://github.com/github/linguist/blob/aad49acc0624c70d654a8dce447887dbbc713c7a/lib/linguist.rb#L14-L49

This addresses src-d/enry#207 because GetLanguages
should not return all candidates detected, otherwise it would work differently
than Linguist.
@bzz
Copy link
Contributor Author

bzz commented Apr 24, 2021

Fixed in the maintained fork now https://github.com/go-enry/go-enry/releases/tag/v2.7.0

@bzz bzz closed this as completed Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant