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

Include the pinned version in brew outdated output for pinned formulae #2401

Merged
merged 3 commits into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions Library/Homebrew/cmd/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def print_outdated(formulae)
"#{full_name} (#{kegs.map(&:version).join(", ")})"
end.join(", ")

puts "#{outdated_versions} < #{current_version}"
pinned_version = " [pinned at #{f.pinned_version}]" if f.pinned?

puts "#{outdated_versions} < #{current_version}#{pinned_version}"
else
puts f.full_installed_specified_name
end
Expand All @@ -86,7 +88,9 @@ def print_outdated_json(formulae)

json << { name: f.full_name,
installed_versions: outdated_versions.collect(&:to_s),
current_version: current_version }
current_version: current_version,
pinned: f.pinned?,
pinned_version: f.pinned_version }
end
puts JSON.generate(json)

Expand Down
92 changes: 84 additions & 8 deletions Library/Homebrew/test/cmd/outdated_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,87 @@
describe "brew outdated", :integration_test do
it "prints outdated Formulae" do
setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath

expect { brew "outdated" }
.to output("testball\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
context "quiet output" do
it "prints outdated Formulae" do
setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath

expect { brew "outdated" }
.to output("testball\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end

context "verbose output" do
it "prints out the installed and newer versions" do
setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath

expect { brew "outdated", "--verbose" }
.to output("testball (0.0.1) < 0.1\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end

context "pinned formula, verbose output" do
it "prints out the pinned version" do
setup_test_formula "testball"
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath

shutup do
expect { brew "pin", "testball" }.to be_a_success
end

expect { brew "outdated", "--verbose" }
.to output("testball (0.0.1) < 0.1 [pinned at 0.0.1]\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
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