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
e97610b9
Commit
e97610b9
authored
9 years ago
by
Xu Cheng
Browse files
Options
Downloads
Patches
Plain Diff
add Tap#install and Tap#uninstall
parent
889bb5fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/cmd/tap.rb
+10
-37
10 additions, 37 deletions
Library/Homebrew/cmd/tap.rb
Library/Homebrew/cmd/untap.rb
+1
-12
1 addition, 12 deletions
Library/Homebrew/cmd/untap.rb
Library/Homebrew/tap.rb
+54
-0
54 additions, 0 deletions
Library/Homebrew/tap.rb
with
65 additions
and
49 deletions
Library/Homebrew/cmd/tap.rb
+
10
−
37
View file @
e97610b9
require
"tap"
require
"descriptions"
module
Homebrew
def
tap
...
...
@@ -14,48 +13,22 @@ module Homebrew
puts
Tap
.
select
(
&
:pinned?
).
map
(
&
:name
)
else
user
,
repo
=
tap_args
clone_target
=
ARGV
.
named
[
1
]
opoo
"
#{
user
}
/
#{
repo
}
already tapped!"
unless
install_tap
(
user
,
repo
,
clone_target
)
tap
=
Tap
.
fetch
(
user
,
repo
)
tap
.
install
(
:clone_target
=>
ARGV
.
named
[
1
],
:full_clone
=>
ARGV
.
include?
(
"--full"
)
)
end
end
# @deprecated this method will be removed in the future, if no external commands use it.
def
install_tap
(
user
,
repo
,
clone_target
=
nil
)
# ensure git is installed
Utils
.
ensure_git_installed!
tap
=
Tap
.
fetch
user
,
repo
return
false
if
tap
.
installed?
ohai
"Tapping
#{
tap
}
"
remote
=
clone_target
||
"https://github.com/
#{
tap
.
user
}
/homebrew-
#{
tap
.
repo
}
"
args
=
%W[clone
#{
remote
}
#{
tap
.
path
}
]
args
<<
"--depth=1"
unless
ARGV
.
include?
(
"--full"
)
opoo
"Homebrew.install_tap is deprecated, use Tap#install."
tap
=
Tap
.
fetch
(
user
,
repo
)
begin
safe_system
"git"
,
*
args
rescue
Interrupt
,
ErrorDuringExecution
ignore_interrupts
do
sleep
0.1
# wait for git to cleanup the top directory when interrupt happens.
tap
.
path
.
parent
.
rmdir_if_possible
end
raise
end
formula_count
=
tap
.
formula_files
.
size
puts
"Tapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
(
#{
tap
.
path
.
abv
}
)"
Descriptions
.
cache_formulae
(
tap
.
formula_names
)
if
!
clone_target
&&
tap
.
private?
puts
<<-
EOS
.
undent
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
#{
tap
.
path
}
git remote set-url origin git@github.com:
#{
tap
.
user
}
/homebrew-
#{
tap
.
repo
}
.git
EOS
tap
.
install
(
:clone_target
=>
clone_target
,
:full_clone
=>
ARGV
.
include?
(
"--full"
))
rescue
TapAlreadyTappedError
false
else
true
end
true
end
# Migrate tapped formulae from symlink-based to directory-based structure.
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/cmd/untap.rb
+
1
−
12
View file @
e97610b9
require
"cmd/tap"
# for tap_args
require
"descriptions"
module
Homebrew
def
untap
...
...
@@ -7,17 +6,7 @@ module Homebrew
ARGV
.
named
.
each
do
|
tapname
|
tap
=
Tap
.
fetch
(
*
tap_args
(
tapname
))
raise
TapUnavailableError
,
tap
.
name
unless
tap
.
installed?
puts
"Untapping
#{
tap
}
... (
#{
tap
.
path
.
abv
}
)"
tap
.
unpin
if
tap
.
pinned?
formula_count
=
tap
.
formula_files
.
size
Descriptions
.
uncache_formulae
(
tap
.
formula_names
)
tap
.
path
.
rmtree
tap
.
path
.
dirname
.
rmdir_if_possible
puts
"Untapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
"
tap
.
uninstall
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/tap.rb
+
54
−
0
View file @
e97610b9
require
"utils/json"
require
"descriptions"
# a {Tap} is used to extend the formulae provided by Homebrew core.
# Usually, it's synced with a remote git repository. And it's likely
...
...
@@ -89,6 +90,59 @@ class Tap
@path
.
directory?
end
# install this {Tap}.
#
# @param [Hash] options
# @option options [String] :clone_targe If passed, it will be used as the clone remote.
# @option options [Boolean] :full_clone If set as true, full clone will be used.
def
install
(
options
=
{})
raise
TapAlreadyTappedError
,
name
if
installed?
# 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
}
]
args
<<
"--depth=1"
unless
options
.
fetch
(
:full_clone
,
false
)
begin
safe_system
"git"
,
*
args
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
end
raise
end
formula_count
=
formula_files
.
size
puts
"Tapped
#{
formula_count
}
formula
#{
plural
(
formula_count
,
"e"
)
}
(
#{
@path
.
abv
}
)"
Descriptions
.
cache_formulae
(
formula_names
)
if
!
options
[
:clone_target
]
&&
private
?
puts
<<-
EOS
.
undent
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
EOS
end
end
# uninstall this {Tap}.
def
uninstall
raise
TapUnavailableError
,
name
unless
installed?
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
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
...
...
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