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
4a7ea6db
Unverified
Commit
4a7ea6db
authored
5 years ago
by
Mike McQuaid
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #6800 from figroc/extract-semver-aware
extract: semver aware
parents
6decac58
3c09ab0d
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/dev-cmd/extract.rb
+15
-5
15 additions, 5 deletions
Library/Homebrew/dev-cmd/extract.rb
Library/Homebrew/test/dev-cmd/extract_spec.rb
+19
-4
19 additions, 4 deletions
Library/Homebrew/test/dev-cmd/extract_spec.rb
with
34 additions
and
9 deletions
Library/Homebrew/dev-cmd/extract.rb
+
15
−
5
View file @
4a7ea6db
...
...
@@ -125,24 +125,34 @@ module Homebrew
if
args
.
version
ohai
"Searching repository history"
version
=
args
.
version
rev
=
"HEAD"
version_segments
=
Gem
::
Version
.
new
(
version
).
segments
if
Gem
::
Version
.
correct?
(
version
)
rev
=
nil
test_formula
=
nil
result
=
""
loop
do
rev
,
(
path
,)
=
Git
.
last_revision_commit_of_files
(
repo
,
pattern
,
before_commit:
"
#{
rev
}
~1"
)
rev
=
rev
.
nil?
?
"HEAD"
:
"
#{
rev
}
~1"
rev
,
(
path
,)
=
Git
.
last_revision_commit_of_files
(
repo
,
pattern
,
before_commit:
rev
)
odie
"Could not find
#{
name
}
! The formula or version may not have existed."
if
rev
.
nil?
file
=
repo
/
path
result
=
Git
.
last_revision_of_file
(
repo
,
file
,
before_commit:
rev
)
if
result
.
empty?
odebug
"Skipping revision
#{
rev
}
- file is empty at this revision"
if
ARGV
.
debug?
odebug
"Skipping revision
#{
rev
}
- file is empty at this revision"
next
end
test_formula
=
formula_at_revision
(
repo
,
name
,
file
,
rev
)
break
if
test_formula
.
nil?
||
test_formula
.
version
==
version
odebug
"Trying
#{
test_formula
.
version
}
from revision
#{
rev
}
against desired
#{
version
}
"
if
ARGV
.
debug?
if
version_segments
&&
Gem
::
Version
.
correct?
(
test_formula
.
version
)
test_formula_version_segments
=
Gem
::
Version
.
new
(
test_formula
.
version
).
segments
if
version_segments
.
length
<
test_formula_version_segments
.
length
odebug
"Apply semantic versioning with
#{
test_formual_version_segments
}
"
break
if
version_segments
==
test_formula_version_segments
.
first
(
version_segments
.
length
)
end
end
odebug
"Trying
#{
test_formula
.
version
}
from revision
#{
rev
}
against desired
#{
version
}
"
end
odie
"Could not find
#{
name
}
! The formula or version may not have existed."
if
test_formula
.
nil?
else
...
...
@@ -181,7 +191,7 @@ module Homebrew
brew extract --force --version=
#{
version
}
#{
name
}
#{
destination_tap
.
name
}
EOS
end
odebug
"Overwriting existing formula at
#{
path
}
"
if
ARGV
.
debug?
odebug
"Overwriting existing formula at
#{
path
}
"
path
.
delete
end
ohai
"Writing formula for
#{
name
}
from revision
#{
rev
}
to
#{
path
}
"
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/dev-cmd/extract_spec.rb
+
19
−
4
View file @
4a7ea6db
...
...
@@ -7,7 +7,7 @@ describe "Homebrew.extract_args" do
end
describe
"brew extract"
,
:integration_test
do
it
"retrieves the specified version of formula, defaulting to most recent"
do
let!
(
:target
)
do
path
=
Tap
::
TAP_DIRECTORY
/
"homebrew/homebrew-foo"
(
path
/
"Formula"
).
mkpath
target
=
Tap
.
from_path
(
path
)
...
...
@@ -23,12 +23,27 @@ describe "brew extract", :integration_test do
system
"git"
,
"add"
,
"--all"
system
"git"
,
"commit"
,
"-m"
,
"testball 0.2"
end
{
name:
target
.
name
,
path:
path
}
end
expect
{
brew
"extract"
,
"testball"
,
target
.
name
,
"--version=0.1"
}
it
"retrieves the most recent version of formula"
do
expect
{
brew
"extract"
,
"testball"
,
target
[
:name
]
}
.
to
be_a_success
expect
(
target
[
:path
]
/
"Formula/testball@0.2.rb"
).
to
exist
expect
(
Formulary
.
factory
(
target
[
:path
]
/
"Formula/testball@0.2.rb"
).
version
).
to
be
==
"0.2"
end
expect
(
path
/
"Formula/testball@0.1.rb"
).
to
exist
it
"retrieves the specified version of formula"
do
expect
{
brew
"extract"
,
"testball"
,
target
[
:name
],
"--version=0.1"
}
.
to
be_a_success
expect
(
target
[
:path
]
/
"Formula/testball@0.1.rb"
).
to
exist
expect
(
Formulary
.
factory
(
target
[
:path
]
/
"Formula/testball@0.1.rb"
).
version
).
to
be
==
"0.1"
end
expect
(
Formulary
.
factory
(
path
/
"Formula/testball@0.1.rb"
).
version
).
to
be
==
"0.1"
it
"retrieves the compatible version of formula"
do
expect
{
brew
"extract"
,
"testball"
,
target
[
:name
],
"--version=0"
,
"--debug"
}
.
to
be_a_success
expect
(
target
[
:path
]
/
"Formula/testball@0.rb"
).
to
exist
expect
(
Formulary
.
factory
(
target
[
:path
]
/
"Formula/testball@0.rb"
).
version
).
to
be
==
"0.2"
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