Skip to content

Commit 4fe423e

Browse files
committed
Support upcoming mas 3.0.0 right-justified app/ADAM IDs from mas list when called from brew bundle.
Signed-off-by: Ross Goldberg <[email protected]>
1 parent 500ec48 commit 4fe423e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Library/Homebrew/bundle/mac_app_store_dumper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.apps
1616
@apps ||= T.let(nil, T.nilable(T::Array[[String, String]]))
1717
@apps ||= if Bundle.mas_installed?
1818
`mas list 2>/dev/null`.split("\n").map do |app|
19-
app_details = app.match(/\A(?<id>\d+)\s+(?<name>.*?)\s+\((?<version>[\d.]*)\)\Z/)
19+
app_details = app.match(/\A\s*(?<id>\d+)\s+(?<name>.*?)\s+\((?<version>[\d.]*)\)\Z/)
2020

2121
# Only add the application details should we have a valid match.
2222
# Strip unprintable characters

Library/Homebrew/test/bundle/mac_app_store_dumper_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
end
5050
end
5151

52+
context "when apps `foo`, `bar`, `baz` and `qux` are installed including right-justified IDs" do
53+
before do
54+
described_class.reset!
55+
allow(Homebrew::Bundle).to receive(:mas_installed?).and_return(true)
56+
allow(described_class).to receive(:`).and_return("123 foo (1.0)\n456 bar (2.0)\n789 baz (3.0)")
57+
allow(described_class).to receive(:`).and_return("123 foo (1.0)\n456 bar (2.0)\n789 baz (3.0)\n 10 qux (4.0)")
58+
end
59+
60+
it "returns list %w[foo bar baz qux]" do
61+
expect(dumper.apps).to eql([["123", "foo"], ["456", "bar"], ["789", "baz"], ["10", "qux"]])
62+
end
63+
end
64+
5265
context "with invalid app details" do
5366
let(:invalid_mas_output) do
5467
<<~HEREDOC

0 commit comments

Comments
 (0)