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
9f7a3830
Commit
9f7a3830
authored
9 years ago
by
Xu Cheng
Browse files
Options
Downloads
Patches
Plain Diff
add CoreFormulaRepository singleton class
parent
c2a5a838
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
+90
-1
90 additions, 1 deletion
Library/Homebrew/tap.rb
with
90 additions
and
1 deletion
Library/Homebrew/tap.rb
+
90
−
1
View file @
9f7a3830
...
...
@@ -16,10 +16,25 @@ class Tap
CACHE
.
clear
end
def
self
.
fetch
(
user
,
repo
)
def
self
.
fetch
(
*
args
)
case
args
.
length
when
1
user
,
repo
=
args
.
first
.
split
(
"/"
,
2
)
when
2
user
=
args
[
0
]
repo
=
args
[
1
]
end
raise
"Invalid tap name"
unless
user
&&
repo
# we special case homebrew so users don't have to shift in a terminal
user
=
"Homebrew"
if
user
==
"homebrew"
repo
=
repo
.
strip_prefix
"homebrew-"
if
user
==
"Homebrew"
&&
repo
==
"homebrew"
return
CoreFormulaRepository
.
instance
end
cache_key
=
"
#{
user
}
/
#{
repo
}
"
.
downcase
CACHE
.
fetch
(
cache_key
)
{
|
key
|
CACHE
[
key
]
=
Tap
.
new
(
user
,
repo
)
}
end
...
...
@@ -302,3 +317,77 @@ class Tap
"
#{
name
}
/
#{
file
.
basename
}
"
end
end
# A specialized {Tap} class to mimic the core formula file system, which shares many
# similarities with normal {Tap}.
# TODO Separate core formulae with core codes. See discussion below for future plan:
# https://github.com/Homebrew/homebrew/pull/46735#discussion_r46820565
class
CoreFormulaRepository
<
Tap
# @private
def
initialize
@user
=
"Homebrew"
@repo
=
"homebrew"
@name
=
"Homebrew/homebrew"
@path
=
HOMEBREW_REPOSITORY
end
def
self
.
instance
@instance
||=
CoreFormulaRepository
.
new
end
# @private
def
uninstall
raise
"Tap#uninstall is not available for CoreFormulaRepository"
end
# @private
def
pin
raise
"Tap#pin is not available for CoreFormulaRepository"
end
# @private
def
unpin
raise
"Tap#unpin is not available for CoreFormulaRepository"
end
# @private
def
pinned?
false
end
# @private
def
command_files
[]
end
# @private
def
custom_remote?
remote
!=
"https://github.com/
#{
user
}
/
#{
repo
}
.git"
end
# @private
def
formula_dir
HOMEBREW_LIBRARY
/
"Formula"
end
# @private
def
alias_dir
HOMEBREW_LIBRARY
/
"Aliases"
end
# @private
def
formula_renames
require
"formula_renames"
FORMULA_RENAMES
end
private
def
formula_file_to_name
(
file
)
file
.
basename
(
".rb"
).
to_s
end
def
alias_file_to_name
(
file
)
file
.
basename
.
to_s
end
end
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