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
89bd945b
Commit
89bd945b
authored
9 years ago
by
Xu Cheng
Browse files
Options
Downloads
Patches
Plain Diff
Tap: use method instead of variable
parent
d20cd244
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/tap.rb
+22
-22
22 additions, 22 deletions
Library/Homebrew/tap.rb
with
22 additions
and
22 deletions
Library/Homebrew/tap.rb
+
22
−
22
View file @
89bd945b
...
...
@@ -55,7 +55,7 @@ class Tap
def
remote
@remote
||=
if
installed?
if
git?
@
path
.
cd
do
path
.
cd
do
Utils
.
popen_read
(
"git"
,
"config"
,
"--get"
,
"remote.origin.url"
).
chomp
end
end
...
...
@@ -66,7 +66,7 @@ class Tap
# True if this {Tap} is a git repository.
def
git?
(
@
path
/
".git"
).
exist?
(
path
/
".git"
).
exist?
end
def
to_s
...
...
@@ -75,13 +75,13 @@ class Tap
# True if this {Tap} is an official Homebrew tap.
def
official?
@
user
==
"Homebrew"
user
==
"Homebrew"
end
# True if the remote of this {Tap} is a private repository.
def
private?
return
true
if
custom_remote?
GitHub
.
private_repo?
(
@
user
,
"homebrew-
#{
@
repo
}
"
)
GitHub
.
private_repo?
(
user
,
"homebrew-
#{
repo
}
"
)
rescue
GitHub
::
HTTPNotFoundError
true
rescue
GitHub
::
Error
...
...
@@ -90,7 +90,7 @@ class Tap
# True if this {Tap} has been installed.
def
installed?
@
path
.
directory?
path
.
directory?
end
# install this {Tap}.
...
...
@@ -104,8 +104,8 @@ class Tap
# ensure git is installed
Utils
.
ensure_git_installed!
ohai
"Tapping
#{
name
}
"
remote
=
options
[
:clone_target
]
||
"https://github.com/
#{
@
user
}
/homebrew-
#{
@
repo
}
"
args
=
%W[clone
#{
remote
}
#{
@
path
}
]
remote
=
options
[
:clone_target
]
||
"https://github.com/
#{
user
}
/homebrew-
#{
repo
}
"
args
=
%W[clone
#{
remote
}
#{
path
}
]
args
<<
"--depth=1"
unless
options
.
fetch
(
:full_clone
,
false
)
begin
...
...
@@ -113,13 +113,13 @@ class Tap
rescue
Interrupt
,
ErrorDuringExecution
ignore_interrupts
do
sleep
0.1
# wait for git to cleanup the top directory when interrupt happens.
@
path
.
parent
.
rmdir_if_possible
path
.
parent
.
rmdir_if_possible
end
raise
end
formula_count
=
formula_files
.
size
puts
"Tapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
(
#{
@
path
.
abv
}
)"
puts
"Tapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
(
#{
path
.
abv
}
)"
Descriptions
.
cache_formulae
(
formula_names
)
if
!
options
[
:clone_target
]
&&
private
?
...
...
@@ -127,8 +127,8 @@ class Tap
It looks like you tapped a private repository. To avoid entering your
credentials each time you update, you can use git HTTP credential
caching or issue the following command:
cd
#{
@
path
}
git remote set-url origin git@github.com:
#{
@
user
}
/homebrew-
#{
@
repo
}
.git
cd
#{
path
}
git remote set-url origin git@github.com:
#{
user
}
/homebrew-
#{
repo
}
.git
EOS
end
end
...
...
@@ -137,24 +137,24 @@ class Tap
def
uninstall
raise
TapUnavailableError
,
name
unless
installed?
puts
"Untapping
#{
name
}
... (
#{
@
path
.
abv
}
)"
puts
"Untapping
#{
name
}
... (
#{
path
.
abv
}
)"
unpin
if
pinned?
formula_count
=
formula_files
.
size
Descriptions
.
uncache_formulae
(
formula_names
)
@
path
.
rmtree
@
path
.
dirname
.
rmdir_if_possible
path
.
rmtree
path
.
dirname
.
rmdir_if_possible
puts
"Untapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
"
end
# True if the {#remote} of {Tap} is customized.
def
custom_remote?
return
true
unless
remote
remote
.
casecmp
(
"https://github.com/
#{
@
user
}
/homebrew-
#{
@
repo
}
"
)
!=
0
remote
.
casecmp
(
"https://github.com/
#{
user
}
/homebrew-
#{
repo
}
"
)
!=
0
end
# an array of all {Formula} files of this {Tap}.
def
formula_files
@formula_files
||=
if
dir
=
[
@
path
/
"Formula"
,
@
path
/
"HomebrewFormula"
,
@
path
].
detect
(
&
:
directory?
)
@formula_files
||=
if
dir
=
[
path
/
"Formula"
,
path
/
"HomebrewFormula"
,
path
].
detect
(
&
:
directory?
)
dir
.
children
.
select
{
|
p
|
p
.
extname
==
".rb"
}
else
[]
...
...
@@ -209,7 +209,7 @@ class Tap
# path to the pin record for this {Tap}.
# @private
def
pinned_symlink_path
HOMEBREW_LIBRARY
/
"PinnedTaps/
#{
@
name
}
"
HOMEBREW_LIBRARY
/
"PinnedTaps/
#{
name
}
"
end
# True if this {Tap} has been pinned.
...
...
@@ -222,7 +222,7 @@ class Tap
def
pin
raise
TapUnavailableError
,
name
unless
installed?
raise
TapPinStatusError
.
new
(
name
,
true
)
if
pinned?
pinned_symlink_path
.
make_relative_symlink
(
@
path
)
pinned_symlink_path
.
make_relative_symlink
(
path
)
@pinned
=
true
end
...
...
@@ -237,10 +237,10 @@ class Tap
def
to_hash
hash
=
{
"name"
=>
@
name
,
"user"
=>
@
user
,
"repo"
=>
@
repo
,
"path"
=>
@
path
.
to_s
,
"name"
=>
name
,
"user"
=>
user
,
"repo"
=>
repo
,
"path"
=>
path
.
to_s
,
"installed"
=>
installed?
,
"official"
=>
official?
,
"formula_names"
=>
formula_names
,
...
...
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