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
137d3329
Commit
137d3329
authored
4 years ago
by
hyuraku
Browse files
Options
Downloads
Patches
Plain Diff
show cask info on browser
parent
48c05037
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/cask/cmd/info.rb
+26
-2
26 additions, 2 deletions
Library/Homebrew/cask/cmd/info.rb
Library/Homebrew/cmd/info.rb
+6
-2
6 additions, 2 deletions
Library/Homebrew/cmd/info.rb
with
32 additions
and
4 deletions
Library/Homebrew/cask/cmd/info.rb
+
26
−
2
View file @
137d3329
...
...
@@ -18,14 +18,38 @@ module Cask
def
self
.
parser
super
do
flag
"--json="
,
description:
"Output information in JSON format."
flag
"--json="
,
description:
"Output information in JSON format."
switch
"--github"
,
description:
"Open the GitHub source page for <Cask> in a browser. "
end
end
def
github_info
(
cask
)
sourcefile_path
=
cask
.
sourcefile_path
dir
=
cask
.
tap
.
path
path
=
sourcefile_path
.
relative_path_from
(
dir
)
remote
=
cask
.
tap
.
remote
github_remote_path
(
remote
,
path
)
end
def
github_remote_path
(
remote
,
path
)
if
remote
=~
%r{^(?:https?://|git(?:@|://))github
\.
com[:/](.+)/(.+?)(?:
\.
git)?$}
"https://github.com/
#{
Regexp
.
last_match
(
1
)
}
/
#{
Regexp
.
last_match
(
2
)
}
/blob/HEAD/
#{
path
}
"
else
"
#{
remote
}
/
#{
path
}
"
end
end
def
run
if
args
.
json
==
"v1"
puts
JSON
.
generate
(
casks
.
map
(
&
:to_h
))
elsif
args
.
github?
raise
CaskUnspecifiedError
if
args
.
no_named?
args
.
named
.
to_formulae_and_casks
.
map
do
|
cask
|
exec_browser
(
github_info
(
cask
))
end
else
casks
.
each_with_index
do
|
cask
,
i
|
puts
unless
i
.
zero?
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/cmd/info.rb
+
6
−
2
View file @
137d3329
...
...
@@ -86,7 +86,7 @@ module Homebrew
elsif
args
.
github?
raise
FormulaUnspecifiedError
if
args
.
no_named?
exec_browser
(
*
args
.
named
.
to_formulae
.
map
{
|
f
|
github_info
(
f
)
})
exec_browser
(
*
args
.
named
.
to_formulae
_and_casks
.
map
{
|
f
|
github_info
(
f
)
})
else
print_info
(
args:
args
)
end
...
...
@@ -148,7 +148,11 @@ module Homebrew
def
github_info
(
f
)
if
f
.
tap
if
remote
=
f
.
tap
.
remote
path
=
f
.
path
.
relative_path_from
(
f
.
tap
.
path
)
path
=
if
f
.
class
.
superclass
==
Formula
f
.
path
.
relative_path_from
(
f
.
tap
.
path
)
elsif
f
.
is_a?
(
Cask
::
Cask
)
f
.
sourcefile_path
.
relative_path_from
(
f
.
tap
.
path
)
end
github_remote_path
(
remote
,
path
)
else
f
.
path
...
...
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