Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #6531 - peret:outdated-filter-dependencies, r=segiddins
Browse files Browse the repository at this point in the history
Add option to filter gem-dependencies from output of 'bundle outdated'

Resolves #5366 by adding a new option '--filter-dependencies' to `bundle outdated`. When present, `outdated` will only check the `gemfile_specs` and skip the `dependency_specs`.

(cherry picked from commit 4eb981a)
  • Loading branch information
bundlerbot authored and colby-swandale committed Oct 5, 2018
1 parent 66f86ee commit 5bf0bc5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def add(gem_name)
method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
"Use minimal formatting for more parseable output"
method_option "only-explicit", :type => :boolean, :banner =>
"Only list gems specified in your Gemfile, not their dependencies"
def outdated(*gems)
require "bundler/cli/outdated"
Outdated.new(options, gems).run
Expand Down
8 changes: 7 additions & 1 deletion lib/bundler/cli/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ def run
current_dependencies.key? spec.name
end

(gemfile_specs + dependency_specs).sort_by(&:name).each do |current_spec|
specs = if options["only-explicit"]
gemfile_specs
else
gemfile_specs + dependency_specs
end

specs.sort_by(&:name).each do |current_spec|
next if !gems.empty? && !gems.include?(current_spec.name)

dependency = current_dependencies[current_spec.name]
Expand Down
4 changes: 4 additions & 0 deletions man/bundle-outdated.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bundle-outdated(1) -- List installed gems with newer versions available
[--filter-major]
[--filter-minor]
[--filter-patch]
[--only-explicit]

## DESCRIPTION

Expand Down Expand Up @@ -67,6 +68,9 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
* `--filter-patch`:
Only list patch newer versions.

* `--only-explicit`:
Only list gems specified in your Gemfile, not their dependencies.

## PATCH LEVEL OPTIONS

See [bundle update(1)](bundle-update.1.html) for details.
Expand Down
27 changes: 27 additions & 0 deletions spec/commands/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,31 @@ def test_group_option(group = nil, gems_list_size = 1)
end
end
end

describe "with --only-explicit" do
it "does not report outdated dependent gems" do
build_repo4 do
build_gem "weakling", %w[0.2 0.3] do |s|
s.add_dependency "bar", "~> 2.1"
end
build_gem "bar", %w[2.1 2.2]
end

install_gemfile <<-G
source "file://#{gem_repo4}"
gem 'weakling', '0.2'
gem 'bar', '2.1'
G

gemfile <<-G
source "file://#{gem_repo4}"
gem 'weakling'
G

bundle "outdated --only-explicit"

expect(out).to include("weakling (newest 0.3")
expect(out).not_to include("bar (newest 2.2")
end
end
end

0 comments on commit 5bf0bc5

Please sign in to comment.