From 2d60187e1a7e168e497fdcc1ba010c963081fc17 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Tue, 6 Oct 2015 23:14:12 +0530 Subject: [PATCH] brew upgrade: provides an option `--cleanup` Closes Homebrew/homebrew#44305. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/upgrade.rb | 6 +++++- Library/Homebrew/manpages/brew.1.md | 4 +++- share/doc/homebrew/brew.1.html | 12 +++++++++++- share/man/man1/brew.1 | 7 +++++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index e1b7dd0dc7..e9d46fa92b 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -1,5 +1,6 @@ require "cmd/install" require "cmd/outdated" +require "cmd/cleanup" module Homebrew def upgrade @@ -41,7 +42,10 @@ module Homebrew puts pinned.map { |f| "#{f.full_name} #{f.pkg_version}" } * ", " end - outdated.each { |f| upgrade_formula(f) } + outdated.each do |f| + upgrade_formula(f) + cleanup_formula(f) if ARGV.include?("--cleanup") && f.installed? + end end def upgrade_pinned? diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md index 06df14196c..4009178dbc 100644 --- a/Library/Homebrew/manpages/brew.1.md +++ b/Library/Homebrew/manpages/brew.1.md @@ -476,11 +476,13 @@ Note that these flags should only appear after a command. If `--rebase` is specified then `git pull --rebase` is used. - * `upgrade [install-options]` []: + * `upgrade [install-options] [--cleanup]` []: Upgrade outdated, unpinned brews. Options for the `install` command are also valid here. + If `--cleanup` is specified then remove previously installed version(s). + If are given, upgrade only the specified brews (but do so even if they are pinned; see `pin`, `unpin`). diff --git a/share/doc/homebrew/brew.1.html b/share/doc/homebrew/brew.1.html index 62d11cee80..dcee76bef6 100644 --- a/share/doc/homebrew/brew.1.html +++ b/share/doc/homebrew/brew.1.html @@ -116,6 +116,14 @@ instead of the intersection.

By default, deps shows dependencies for formulae. To skip the :build type dependencies, pass --skip-build. Similarly, pass --skip-optional to skip :optional dependencies.

+
  • desc formula: +Display formula's name and one-line description.

  • +
  • desc [-s|-n|-d] <pattern>: +Search both name and description (-s), just the names (-n), or just the +descriptions (-d) for <pattern>. <pattern> is by default interpreted +as a literal string; if flanked by slashes, it is instead interpreted as a +regular expression. Formula descriptions are cached; the cache is created on +the first search, making that search slower than subsequent ones.

  • diy [--name=<name>] [--version=<version>]: Automatically determine the installation prefix for non-Homebrew software.

    @@ -409,11 +417,13 @@ Fetch the newest version of Homebrew and all formulae from GitHub using git(1).

    If --rebase is specified then git pull --rebase is used.

  • -
  • upgrade [install-options] [formulae]: +

  • upgrade [install-options] [--cleanup] [formulae]: Upgrade outdated, unpinned brews.

    Options for the install command are also valid here.

    +

    If --cleanup is specified then remove previously installed formula version(s).

    +

    If formulae are given, upgrade only the specified brews (but do so even if they are pinned; see pin, unpin).

  • uses [--installed] [--recursive] [--skip-build] [--skip-optional] [--devel|--HEAD] formulae: diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index 0179f0ef4f..639768398c 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "September 2015" "Homebrew" "brew" +.TH "BREW" "1" "October 2015" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for OS X @@ -448,12 +448,15 @@ If \fB\-\-git\fR is passed, a Git repository will be initalized in the unpacked If \fB\-\-rebase\fR is specified then \fBgit pull \-\-rebase\fR is used\. . .IP "\(bu" 4 -\fBupgrade [install\-options]\fR [\fIformulae\fR]: Upgrade outdated, unpinned brews\. +\fBupgrade [install\-options] [\-\-cleanup]\fR [\fIformulae\fR]: Upgrade outdated, unpinned brews\. . .IP Options for the \fBinstall\fR command are also valid here\. . .IP +If \fB\-\-cleanup\fR is specified then remove previously installed \fIformula\fR version(s)\. +. +.IP If \fIformulae\fR are given, upgrade only the specified brews (but do so even if they are pinned; see \fBpin\fR, \fBunpin\fR)\. . .IP "\(bu" 4