mirror of
https://github.com/goodhosts/hostsfile.git
synced 2026-04-27 15:35:50 +03:00
[GH-ISSUE #40] HostsPerLine is destructive #14
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hostsfile#14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tomjn on GitHub (Dec 4, 2022).
Original GitHub issue: https://github.com/goodhosts/hostsfile/issues/40
The
HostsPerLinefunction is destructive, and does a number of unexpected things:I believe this is related to https://github.com/goodhosts/vagrant/issues/51
@jd4u commented on GitHub (Dec 4, 2022):
The issue seems to be in goodhosts/cli project. With or without "--clean" flag, cli is performing clean process. See Issue Comment
The cli project seems to be handling bool value incorrectly. Explicitly setting default bool value may help.
@tomjn commented on GitHub (Dec 4, 2022):
Note that I cannot reproduce this on MacOS, this is very likely Windows related.
We need to confirm what the command is doing to the hosts file in addition to stripping out comments to eliminate options, my current theory is that this has nothing to do with the clean parameters, but due to the attempt to workaround a Windows bug where more than 8 hosts on a line breaks the hosts file.
We can confirm this if we had examples that can be used to see if it's sorting the hosts file, merging lines that were previously separate, etc
@tomjn commented on GitHub (Dec 4, 2022):
@luthermonson is it possible that this is all because of the Ip de-duplication at the top of that function?
@tomjn commented on GitHub (Dec 4, 2022):
For context @jd4u is reporting that comments were stripped from their hosts file on use regardless of wether the clean parameter was specified or not. They're a WIndows user so
HostsPerLinewould be running to cap the lines at 8 hosts, is theRemoveDuplicateIpsreally necessary?@jd4u commented on GitHub (Dec 4, 2022):
Yes @tomjn, you may be pointing right place.
RemoveDuplicateIpsis called withinCleanalong withHostsPerLineCleanfunction does Sort before makingHostsPerLine.RemoveDuplicateIpsis called fromHostsPerLinetoo.HostsPerLine,RemoveDuplicateIpsare called.@jd4u commented on GitHub (Dec 4, 2022):
Just for note,
@rfay commented on GitHub (Apr 6, 2023):
Comments are stripped regardless of the cli.
This is easy to demonstrate with https://github.com/rfay/goodhostsbug
@rfay commented on GitHub (Apr 6, 2023):
One improvement here would be to respect "important" standard lines like "localhost". A longer-term improvement would be to add separate lines for goodhosts-managed lines (probably marked with a comment before and after).
@rfay commented on GitHub (Oct 27, 2023):
I've seen some good maintenance going on in this area lately, thanks! Has this one been addressed yet?
@luthermonson commented on GitHub (Oct 27, 2023):
ya all that stuff got refactored to index the lookup hashmaps better. i bet your example repo works against latest main, give it a check and report back findings and ill fix if still broke
@rfay commented on GitHub (Oct 27, 2023):
No, it still makes a pretty big mess. Comments are mostly destroyed and misplaced. I updated https://github.com/rfay/goodhostsbug and its readme to show more how to demonstrate it.
Bottom line is that
gets transformed to
@luthermonson commented on GitHub (Oct 28, 2023):
im sorry i wasted your time... I forgot I hadn't released the changes here https://github.com/goodhosts/hostsfile/pull/46
please try with v0.1.4 as with a test off latest main i got the following...
@rfay commented on GitHub (Oct 28, 2023):
Yay, it's working great! This issue can be closed (at least about the comments), thanks so much!
@luthermonson commented on GitHub (Oct 28, 2023):
My pleasure! Glad it's working
@rfay commented on GitHub (Oct 28, 2023):
Thanks so much for your maintenance of this! Reopened