Add pinned version to outdated json output
The structure should be consistent, so there are always pinned and pinned_version fields even if there are no pinned versions for a given formula.
This commit is contained in:
parent
70446d9112
commit
996dcdee2c
@ -88,7 +88,9 @@ module Homebrew
|
|||||||
|
|
||||||
json << { name: f.full_name,
|
json << { name: f.full_name,
|
||||||
installed_versions: outdated_versions.collect(&:to_s),
|
installed_versions: outdated_versions.collect(&:to_s),
|
||||||
current_version: current_version }
|
current_version: current_version,
|
||||||
|
pinned: f.pinned?,
|
||||||
|
pinned_version: f.pinned_version }
|
||||||
end
|
end
|
||||||
puts JSON.generate(json)
|
puts JSON.generate(json)
|
||||||
|
|
||||||
|
|||||||
@ -38,4 +38,50 @@ describe "brew outdated", :integration_test do
|
|||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "json output" do
|
||||||
|
it "includes pinned version in the json output" do
|
||||||
|
setup_test_formula "testball"
|
||||||
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
|
|
||||||
|
shutup do
|
||||||
|
expect { brew "pin", "testball" }.to be_a_success
|
||||||
|
end
|
||||||
|
|
||||||
|
expected_json = [
|
||||||
|
{
|
||||||
|
name: "testball",
|
||||||
|
installed_versions: ["0.0.1"],
|
||||||
|
current_version: "0.1",
|
||||||
|
pinned: true,
|
||||||
|
pinned_version: "0.0.1",
|
||||||
|
},
|
||||||
|
].to_json
|
||||||
|
|
||||||
|
expect { brew "outdated", "--json=v1" }
|
||||||
|
.to output(expected_json + "\n").to_stdout
|
||||||
|
.and not_to_output.to_stderr
|
||||||
|
.and be_a_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has no pinned version when the formula isn't pinned" do
|
||||||
|
setup_test_formula "testball"
|
||||||
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
|
|
||||||
|
expected_json = [
|
||||||
|
{
|
||||||
|
name: "testball",
|
||||||
|
installed_versions: ["0.0.1"],
|
||||||
|
current_version: "0.1",
|
||||||
|
pinned: false,
|
||||||
|
pinned_version: nil,
|
||||||
|
},
|
||||||
|
].to_json
|
||||||
|
|
||||||
|
expect { brew "outdated", "--json=v1" }
|
||||||
|
.to output(expected_json + "\n").to_stdout
|
||||||
|
.and not_to_output.to_stderr
|
||||||
|
.and be_a_success
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user