diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 192b0beb8e..02bd489a43 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -1,4 +1,4 @@ -#: * `upgrade` [] [`--cleanup`] [`--fetch-HEAD`] []: +#: * `upgrade` [] [`--cleanup`] [`--fetch-HEAD`] [`--ignore-pinned`] []: #: Upgrade outdated, unpinned brews (with existing install options). #: #: Options for the `install` command are also valid here. @@ -11,6 +11,9 @@ #: repository's HEAD will be checked for updates when a new stable or devel #: version has been released. #: +#: If `--ignore-pinned` is passed, set a 0 exit code even if pinned formulae +#: are not upgraded. +#: #: If are given, upgrade only the specified brews (unless they #: are pinned; see `pin`, `unpin`). @@ -55,6 +58,11 @@ module Homebrew outdated -= pinned formulae_to_install = outdated.map(&:latest_formula) + if !pinned.empty? && !ARGV.include?("--ignore-pinned") + ofail "Not upgrading #{Formatter.pluralize(pinned.length, "pinned package")}:" + puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " + end + if formulae_to_install.empty? oh1 "No packages to upgrade" else @@ -62,11 +70,6 @@ module Homebrew puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " end - unless pinned.empty? - onoe "Not upgrading #{Formatter.pluralize(pinned.length, "pinned package")}:" - puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " - end - # Sort keg_only before non-keg_only formulae to avoid any needless conflicts # with outdated, non-keg_only versions of formulae being upgraded. formulae_to_install.sort! do |a, b| diff --git a/Library/Homebrew/test/cmd/pin_spec.rb b/Library/Homebrew/test/cmd/pin_spec.rb index a8f680d717..9f2dad8a3d 100644 --- a/Library/Homebrew/test/cmd/pin_spec.rb +++ b/Library/Homebrew/test/cmd/pin_spec.rb @@ -4,7 +4,7 @@ describe "brew pin", :integration_test do (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath expect { brew "pin", "testball" }.to be_a_success - expect { brew "upgrade" }.to be_a_success + expect { brew "upgrade" }.to be_a_failure expect(HOMEBREW_CELLAR/"testball/0.1").not_to be_a_directory end diff --git a/docs/Manpage.md b/docs/Manpage.md index c4706e9d25..0ce63adfab 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -552,7 +552,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note their latest `origin/master`. Note this will destroy all your uncommitted or committed changes. - * `upgrade` [`install-options`] [`--cleanup`] [`--fetch-HEAD`] [`formulae`]: + * `upgrade` [`install-options`] [`--cleanup`] [`--fetch-HEAD`] [`--ignore-pinned`] [`formulae`]: Upgrade outdated, unpinned brews (with existing install options). Options for the `install` command are also valid here. @@ -565,6 +565,9 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note repository's HEAD will be checked for updates when a new stable or devel version has been released. + If `--ignore-pinned` is passed, set a 0 exit code even if pinned formulae + are not upgraded. + If `formulae` are given, upgrade only the specified brews (unless they are pinned; see `pin`, `unpin`). diff --git a/manpages/brew.1 b/manpages/brew.1 index 3b2d200af4..20e51f6619 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -566,7 +566,7 @@ If \fB\-\-force\fR (or \fB\-f\fR) is specified then always do a slower, full upd Fetches and resets Homebrew and all tap repositories using \fBgit\fR(1) to their latest \fBorigin/master\fR\. Note this will destroy all your uncommitted or committed changes\. . .TP -\fBupgrade\fR [\fIinstall\-options\fR] [\fB\-\-cleanup\fR] [\fB\-\-fetch\-HEAD\fR] [\fIformulae\fR] +\fBupgrade\fR [\fIinstall\-options\fR] [\fB\-\-cleanup\fR] [\fB\-\-fetch\-HEAD\fR] [\fB\-\-ignore\-pinned\fR] [\fIformulae\fR] Upgrade outdated, unpinned brews (with existing install options)\. . .IP @@ -579,6 +579,9 @@ If \fB\-\-cleanup\fR is specified or \fBHOMEBREW_UPGRADE_CLEANUP\fR is set then If \fB\-\-fetch\-HEAD\fR is passed, fetch the upstream repository to detect if the HEAD installation of the formula is outdated\. Otherwise, the repository\'s HEAD will be checked for updates when a new stable or devel version has been released\. . .IP +If \fB\-\-ignore\-pinned\fR is passed, set a 0 exit code even if pinned formulae are not upgraded\. +. +.IP If \fIformulae\fR are given, upgrade only the specified brews (unless they are pinned; see \fBpin\fR, \fBunpin\fR)\. . .TP