diff options
| author | Mike McQuaid | 2017-03-30 20:24:30 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-30 20:24:30 +0100 |
| commit | b6792fc7be1c972dced077940bd135a5bafe5671 (patch) | |
| tree | 9b199ac1fe60c2607556815c4221882a2d539804 /Library/Homebrew | |
| parent | 3805850eb3252adb51d25a298961c1effec1e559 (diff) | |
| parent | 996dcdee2cacdfee90602387d5c5142d749f00de (diff) | |
| download | brew-b6792fc7be1c972dced077940bd135a5bafe5671.tar.bz2 | |
Merge pull request #2401 from wjlroe/print-pinned-on-outdated
Include the pinned version in brew outdated output for pinned formulae
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/cmd/outdated.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/cmd/outdated_spec.rb | 92 |
2 files changed, 90 insertions, 10 deletions
diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index a18f4e399..e94002989 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -64,7 +64,9 @@ module Homebrew "#{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 @@ -86,7 +88,9 @@ module Homebrew 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) diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb index 2ce0825e8..65cce27c3 100644 --- a/Library/Homebrew/test/cmd/outdated_spec.rb +++ b/Library/Homebrew/test/cmd/outdated_spec.rb @@ -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 |
