Skip to content

Commit

Permalink
refactor: clarify extend host method
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael DEMACON <[email protected]>
  • Loading branch information
quantumsheep committed Feb 21, 2024
1 parent 126bb7a commit 4731303
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/ssh_config/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ impl Host {
self.entries.insert(entry.0, entry.1);
}

pub(crate) fn extend(&mut self, host: &Host) {
pub(crate) fn extend_patterns(&mut self, host: &Host) {
self.patterns.extend(host.patterns.clone());
}

pub(crate) fn extend_entries(&mut self, host: &Host) {
self.entries.extend(host.entries.clone());
}

Expand Down Expand Up @@ -108,7 +111,8 @@ impl HostVecExt for Vec<Host> {
}

let host = self[i].clone();
self[j].extend(&host);
self[j].extend_patterns(&host);
self[j].extend_entries(&host);
self.remove(i);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ssh_config/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Parser {

if hosts.is_empty() {
if !included_global_host.is_empty() {
global_host.extend(&included_global_host);
global_host.extend_entries(&included_global_host);
}

hosts.extend(included_hosts);
Expand All @@ -106,7 +106,7 @@ impl Parser {
return Err("Cannot include hosts inside a host block".into());
}

hosts.last_mut().unwrap().extend(&included_global_host);
hosts.last_mut().unwrap().extend_entries(&included_global_host);
}

continue;
Expand Down

0 comments on commit 4731303

Please sign in to comment.