Skip to content
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

vscode_extension cleanup: downcase extension names before comparison while evaluating for cleanup #1304

Merged
merged 7 commits into from
Feb 9, 2024
2 changes: 1 addition & 1 deletion lib/bundle/commands/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def taps_to_untap(global: false, file: nil)

def vscode_extensions_to_uninstall(global: false, file: nil)
@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
kept_extensions = @dsl.entries.select { |e| e.type == :vscode }.map(&:name)
kept_extensions = @dsl.entries.select { |e| e.type == :vscode }.map { |x| x.name.downcase }

# To provide a graceful migration from `Brewfile`s that don't yet or
# don't want to use `vscode`: don't remove any extensions if we don't
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/vscode_extension_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa
end

def extension_installed?(name)
installed_extensions.include? name
installed_extensions.include? name.downcase
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
end

def installed_extensions
Expand Down
7 changes: 6 additions & 1 deletion spec/bundle/commands/cleanup_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
brew 'hasbuilddependency1'
brew 'hasbuilddependency2'
mas 'appstoreapp1', id: 1
vscode 'vscodeextension1'
vscode 'VsCodeExtension1'
EOS
end

Expand Down Expand Up @@ -76,6 +76,11 @@
allow(Bundle::VscodeExtensionDumper).to receive(:extensions).and_return(%w[z])
expect(described_class.vscode_extensions_to_uninstall).to eql(%w[z])
end

it "computes which VSCode extensions to uninstall irrespective of case of the extension name" do
vraravam marked this conversation as resolved.
Show resolved Hide resolved
allow(Bundle::VscodeExtensionDumper).to receive(:extensions).and_return(%w[z vscodeextension1])
expect(described_class.vscode_extensions_to_uninstall).to eql(%w[z])
end
end

context "when there are no formulae to uninstall and no taps to untap" do
Expand Down
5 changes: 5 additions & 0 deletions spec/bundle/vscode_extension_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
expect(Bundle).not_to receive(:system)
expect(described_class.preinstall("foo")).to be(false)
end

it "skips ignoring case" do
vraravam marked this conversation as resolved.
Show resolved Hide resolved
expect(Bundle).not_to receive(:system)
expect(described_class.preinstall("Foo")).to be(false)
end
end

context "when app is not installed" do
Expand Down
Loading