Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test and case insensitivity
  • Loading branch information
mafredri committed Jul 8, 2024
commit 8e131ebc5eb0eae380e732c10bd5fd2ac940a704
5 changes: 3 additions & 2 deletions cli/configssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func (o *sshConfigOptions) addOption(option string) error {
if err != nil {
return err
}
if o.removedKeys != nil && o.removedKeys[key] {
lowerKey := strings.ToLower(key)
if o.removedKeys != nil && o.removedKeys[lowerKey] {
// Key marked as removed, skip.
return nil
}
Expand All @@ -87,7 +88,7 @@ func (o *sshConfigOptions) addOption(option string) error {
if o.removedKeys == nil {
o.removedKeys = make(map[string]bool)
}
o.removedKeys[key] = true
o.removedKeys[lowerKey] = true
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions cli/configssh_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,32 +272,32 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
},
},
{
Name: "Replace",
Name: "AddTwo",
Start: []string{
"foo bar",
},
Add: []string{"Foo baz"},
Expect: []string{
"foo bar",
"Foo baz",
},
},
{
Name: "AddAndReplace",
Name: "AddAndRemove",
Start: []string{
"a b",
"foo bar",
"buzz bazz",
},
Add: []string{
"b c",
"a=", // Remove all entries that start with "a", i.e. next line.
"A hello",
"hello world",
},
Expect: []string{
"foo bar",
"buzz bazz",
"b c",
"A hello",
"hello world",
},
},
Expand Down