-
Notifications
You must be signed in to change notification settings - Fork 49
fix includes parsing #119
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
fix includes parsing #119
Conversation
013a535 to
d2e8327
Compare
src/ssh_config/parser.rs
Outdated
|
|
||
| if patterns.contains(&"*".to_string()) { | ||
| global_host = Host::new(patterns.clone()); | ||
| hosts.push(global_host.clone()); |
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.
This would add an host with patterns but empty entries. I'm not sure if it's needed 🤔 global_host by itself may not be needed as we have current_host now.
src/ssh_config/parser.rs
Outdated
| let mut global_host = Host::new(Vec::new()); | ||
| let mut is_in_host_block = false; | ||
| let mut hosts = Vec::new(); | ||
| let mut current_host: Option<Host> = None; |
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.
| let mut current_host: Option<Host> = None; | |
| let mut current_host = Host::new(vec!["*".to_string()]); |
current_host is the global host by default. What about this?
d2e8327 to
50da653
Compare
|
@quantumsheep sorry for wasting your time reviewing the previous commit. i think we can simplify this fix to: if !patterns.contains(&"*".to_string()) {
is_in_host_block = true;
hosts.push(Host::new(patterns));
}after this, everything from Offtopic:While working on the task, I discovered a not quite correct behaviour: according to the specification, the entries below cannot overwrite those already declared above. Case:
|
I think it's not right too. What about I think we should just set current host when an host in host is found. Wildcards are handled by What do you think? Really sorry to make you change your code multiple times. |
|
Hey! I took the original idea and simplified it in f04c0b4. Thanks a lot! |
fixes #118
My first experience with Rust. I didn't understand why the InvalidIncludeErrorDetails::HostsInsideHostBlock case is needed, but I can fix the code if you suggest a couple of examples for tests)