Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
22c2b06f
Unverified
Commit
22c2b06f
authored
6 years ago
by
Gautham Goli
Committed by
Mike McQuaid
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmd/upgrade: Use CLI::Parser to parse args
parent
3bdc4c29
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/cmd/upgrade.rb
+37
-10
37 additions, 10 deletions
Library/Homebrew/cmd/upgrade.rb
with
37 additions
and
10 deletions
Library/Homebrew/cmd/upgrade.rb
+
37
−
10
View file @
22c2b06f
...
...
@@ -23,10 +23,37 @@ require "formula_installer"
require
"development_tools"
require
"messages"
require
"cleanup"
require
"cli_parser"
module
Homebrew
module_function
def
upgrade_args
Homebrew
::
CLI
::
Parser
.
new
do
usage_banner
<<~
EOS
`upgrade` [<install-options>] [<options>] [<formulae>]
Upgrade outdated, unpinned brews (with existing install options).
Options for the `install` command are also valid here.
If <formulae> are given, upgrade only the specified brews (unless they
are pinned; see `pin`, `unpin`).
EOS
switch
"--fetch-HEAD"
,
description:
"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."
switch
"--ignore-pinned"
,
description:
"Set a 0 exit code even if pinned formulae are not upgraded."
switch
"--build-bottle"
,
description:
"Prepare the formula for eventual bottling during installation."
switch
"--display-times"
,
description:
"Print install times for each formula at the end of the run."
switch
:verbose
switch
:debug
end
end
def
upgrade
if
ARGV
.
include?
(
"--cleanup"
)
odisabled
(
"'brew upgrade --cleanup'"
)
...
...
@@ -40,13 +67,13 @@ module Homebrew
if
ARGV
.
named
.
empty?
outdated
=
Formula
.
installed
.
select
do
|
f
|
f
.
outdated?
(
fetch_head:
ARGV
.
fetch_
head
?
)
f
.
outdated?
(
fetch_head:
args
.
fetch_
HEAD
?
)
end
exit
0
if
outdated
.
empty?
else
outdated
=
ARGV
.
resolved_formulae
.
select
do
|
f
|
f
.
outdated?
(
fetch_head:
ARGV
.
fetch_
head
?
)
f
.
outdated?
(
fetch_head:
args
.
fetch_
HEAD
?
)
end
(
ARGV
.
resolved_formulae
-
outdated
).
each
do
|
f
|
...
...
@@ -65,7 +92,7 @@ module Homebrew
outdated
-=
pinned
formulae_to_install
=
outdated
.
map
(
&
:latest_formula
)
if
!
pinned
.
empty?
&&
!
ARGV
.
include?
(
"--
ignore
-
pinned
"
)
if
!
pinned
.
empty?
&&
!
args
.
ignore
_
pinned
?
ofail
"Not upgrading
#{
pinned
.
count
}
pinned
#{
"package"
.
pluralize
(
pinned
.
count
)
}
:"
puts
pinned
.
map
{
|
f
|
"
#{
f
.
full_specified_name
}
#{
f
.
pkg_version
}
"
}
*
", "
end
...
...
@@ -144,7 +171,7 @@ module Homebrew
fi
=
FormulaInstaller
.
new
(
f
)
fi
.
options
=
options
fi
.
build_bottle
=
ARGV
.
build_bottle?
||
(
!
f
.
bottle_defined?
&&
f
.
build
.
bottle?
)
fi
.
build_bottle
=
args
.
build_bottle?
||
(
!
f
.
bottle_defined?
&&
f
.
build
.
bottle?
)
fi
.
installed_on_request
=
!
ARGV
.
named
.
empty?
fi
.
link_keg
||=
keg_was_linked
if
keg_had_linked_opt
if
tab
...
...
@@ -203,7 +230,7 @@ module Homebrew
next
if
formulae_to_upgrade
.
include?
(
f
)
next
if
formulae_pinned
.
include?
(
f
)
if
f
.
outdated?
(
fetch_head:
ARGV
.
fetch_
head
?
)
if
f
.
outdated?
(
fetch_head:
args
.
fetch_
HEAD
?
)
if
f
.
pinned?
formulae_pinned
<<
f
else
...
...
@@ -247,7 +274,7 @@ module Homebrew
checker
=
LinkageChecker
.
new
(
keg
,
cache_db:
db
)
if
checker
.
broken_library_linkage?
if
f
.
outdated?
(
fetch_head:
ARGV
.
fetch_
head
?
)
if
f
.
outdated?
(
fetch_head:
args
.
fetch_
HEAD
?
)
# Outdated formulae = pinned formulae (see function above)
formulae_pinned_and_outdated
<<
f
else
...
...
@@ -295,7 +322,7 @@ module Homebrew
return
if
kegs
.
empty?
oh1
"Checking dependents for outdated formulae"
if
ARGV
.
verbose?
oh1
"Checking dependents for outdated formulae"
if
args
.
verbose?
upgradable
,
pinned
=
upgradable_dependents
(
kegs
,
formulae
).
map
(
&
:to_a
)
upgradable
.
sort!
{
|
a
,
b
|
depends_on
(
a
,
b
)
}
...
...
@@ -310,7 +337,7 @@ module Homebrew
# Print the upgradable dependents.
if
upgradable
.
empty?
ohai
"No dependents to upgrade"
if
ARGV
.
verbose?
ohai
"No dependents to upgrade"
if
args
.
verbose?
else
ohai
"Upgrading
#{
upgradable
.
count
}
#{
"dependent"
.
pluralize
(
upgradable
.
count
)
}
:"
formulae_upgrades
=
upgradable
.
map
do
|
f
|
...
...
@@ -328,7 +355,7 @@ module Homebrew
# Assess the dependents tree again.
kegs
=
formulae_with_runtime_dependencies
oh1
"Checking dependents for broken library links"
if
ARGV
.
verbose?
oh1
"Checking dependents for broken library links"
if
args
.
verbose?
reinstallable
,
pinned
=
broken_dependents
(
kegs
,
formulae
).
map
(
&
:to_a
)
reinstallable
.
sort!
{
|
a
,
b
|
depends_on
(
a
,
b
)
}
...
...
@@ -343,7 +370,7 @@ module Homebrew
# Print the broken dependents.
if
reinstallable
.
empty?
ohai
"No broken dependents to reinstall"
if
ARGV
.
verbose?
ohai
"No broken dependents to reinstall"
if
args
.
verbose?
else
ohai
"Reinstalling
#{
reinstallable
.
count
}
broken
#{
"dependent"
.
pluralize
(
reinstallable
.
count
)
}
from source:"
puts
reinstallable
.
map
(
&
:full_specified_name
).
join
(
", "
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment