-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add language support for hosts
files
#6391
Conversation
Still incomplete; real-world usage suggests that generic filenames might be necessary (we currently only support generic *file extensions*).
@lildude Any idea how we can get our tests to pass when both Failed tests1) Failure: TestSamples#test_Hosts File_has_samples [/home/runner/work/linguist/linguist/test/test_samples.rb:96]: Missing sample in "samples/Hosts File/filenames/HOSTS". See https://github.com/github/linguist/blob/master/CONTRIBUTING.md 2) Failure: TestSamples#test_INI_has_samples [/home/runner/work/linguist/linguist/test/test_samples.rb:96]: Missing sample in "samples/INI/filenames/HOSTS". See https://github.com/github/linguist/blob/master/CONTRIBUTING.md (This would be a non-issue if Linguist matched filenames case-insensitively, the way it does with file extensions). |
I thought about this in #6364 and I'm still not sure it's worth the effort, but I'm open to being convinced with a compelling argument 😁.
Fudge it 😁. This simplest "solution" is skip the tests just for this language. Are more convoluted "solution" is we adjust the various logic and use something like an underscore after these filenames, eg Either way, I don't think we need to get too fancy right now as I don't expect this to be particularly common. |
Yeah, me neither. 😀 I've added a comment with a permalink to your response (since this is the sort of last-minute hack that's all but indecipherable to my future self, give or take 2-3 years…) |
Output of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments
If I understand the CSON syntax correctly (There's a high chance that I don't), then I can't seem to get
I therefore wonder if |
@DandelionSprout I've already started work on improving the accuracy of matching IP addresses in FYI, "work" includes reading up on CIDR notation, IPv6 addresses, subnet masks, and various other concepts I was entirely unfamiliar with until now. Highlighting IPv6 addresses in a self-validating manner might be impossible (or at least unreasonable), so expect some leniency in terms of digit-omission. |
So, now that this has been merged, which colours will end up being used in Hosts files and for which things, and is there a timeline for when such colours would begin to appear in GitHub's web GUI? Edit: I now see that |
Description
This PR adds language support for
hosts
files, as detailed by @DandelionSprout in #6389.Usage
A filename search for
hosts
yields over ~25,200 results. Most of these are legithosts(5)
files, but a non-trivial number of them aren't (such as this). I contemplating registering this a generic extension, but quickly realised this feature only accommodates file-extensions, not unabridged filenames (which are handled by two different classification strategies). I'm wondering if the “generic filetypes” feature added to Linguist in 2020 should accommodate “generic filenames” as well. @lildude, any thoughts?Checklist
~25.2k search results for the filename
hosts
.samples/Hosts File/filenames/hosts
samples/INI/filenames/hosts
PacktPublishing/Ansible-for-Real-life-Automation
2includedupdated a syntax highlighting grammar.langauge-etc
already includes a grammar for highlightinghosts(5)
syntax#308888
I have updated the heuristics.Closes #6389
Footnotes
File is ineligible for copyright, at least according to my reading of Wikipedia. ↩
Concatenated from several configuration examples embedded in markdown files. ↩