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
88ebbd56
Commit
88ebbd56
authored
4 years ago
by
Seeker
Browse files
Options
Downloads
Patches
Plain Diff
bump-formula-pr: make `--dry-run` conflict with `--write`
Also add `--commit` to a create commit without opening a pull request
parent
537a93ce
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/dev-cmd/bump-formula-pr.rb
+33
-25
33 additions, 25 deletions
Library/Homebrew/dev-cmd/bump-formula-pr.rb
docs/Manpage.md
+3
-1
3 additions, 1 deletion
docs/Manpage.md
manpages/brew.1
+5
-1
5 additions, 1 deletion
manpages/brew.1
with
41 additions
and
27 deletions
Library/Homebrew/dev-cmd/bump-formula-pr.rb
+
33
−
25
View file @
88ebbd56
...
...
@@ -32,9 +32,11 @@ module Homebrew
switch
"-n"
,
"--dry-run"
,
description:
"Print what would be done rather than doing it."
switch
"--write"
,
depends_on:
"--dry-run"
,
description:
"When passed along with `--dry-run`, perform a not-so-dry run by making the expected "
\
"file modifications but not taking any Git actions."
description:
"Make the expected file modifications without taking any Git actions."
switch
"--commit"
,
depends_on:
"--write"
,
description:
"When passed with `--write`, generate a new commit after writing changes "
\
"to the formula file."
switch
"--no-audit"
,
description:
"Don't run `brew audit` before opening the PR."
switch
"--strict"
,
...
...
@@ -66,6 +68,7 @@ module Homebrew
switch
"-f"
,
"--force"
,
description:
"Ignore duplicate open PRs. Remove all mirrors if --mirror= was not specified."
conflicts
"--dry-run"
,
"--write"
conflicts
"--no-audit"
,
"--strict"
conflicts
"--url"
,
"--tag"
max_named
1
...
...
@@ -83,7 +86,7 @@ module Homebrew
previous_branch
=
"master"
if
previous_branch
.
empty?
formula_path
=
formula
.
path
.
to_s
[
%r{(Formula/.*)}
,
1
]
if
args
.
dry_run?
if
args
.
dry_run?
||
args
.
write?
ohai
"git remote add
#{
homebrew_core_remote
}
#{
homebrew_core_url
}
"
ohai
"git fetch
#{
homebrew_core_remote
}
#{
homebrew_core_branch
}
"
ohai
"git cat-file -e
#{
origin_branch
}
:
#{
formula_path
}
"
...
...
@@ -245,8 +248,7 @@ module Homebrew
]
end
read_only_run
=
args
.
dry_run?
&&
!
args
.
write?
old_contents
=
File
.
read
(
formula
.
path
)
unless
read_only_run
old_contents
=
File
.
read
(
formula
.
path
)
unless
args
.
dry_run?
if
new_mirrors
replacement_pairs
<<
[
...
...
@@ -296,7 +298,7 @@ module Homebrew
end
new_contents
=
Utils
::
Inreplace
.
inreplace_pairs
(
formula
.
path
,
replacement_pairs
.
uniq
.
compact
,
read_only_run:
read_onl
y_run
,
read_only_run:
args
.
dr
y_run
?
,
silent:
args
.
quiet?
)
new_formula_version
=
formula_version
(
formula
,
requested_spec
,
new_contents
)
...
...
@@ -313,13 +315,13 @@ module Homebrew
end
if
new_formula_version
<
old_formula_version
formula
.
path
.
atomic_write
(
old_contents
)
unless
read_onl
y_run
formula
.
path
.
atomic_write
(
old_contents
)
unless
args
.
dr
y_run
?
odie
<<~
EOS
You need to bump this formula manually since changing the
version from
#{
old_formula_version
}
to
#{
new_formula_version
}
would be a downgrade.
EOS
elsif
new_formula_version
==
old_formula_version
formula
.
path
.
atomic_write
(
old_contents
)
unless
read_onl
y_run
formula
.
path
.
atomic_write
(
old_contents
)
unless
args
.
dr
y_run
?
odie
<<~
EOS
You need to bump this formula manually since the new version
and old version are both
#{
new_formula_version
}
.
...
...
@@ -332,7 +334,7 @@ module Homebrew
alias_rename
.
map!
{
|
a
|
formula
.
tap
.
alias_dir
/
a
}
end
unless
read_onl
y_run
unless
args
.
dr
y_run
?
PyPI
.
update_python_resources!
formula
,
new_formula_version
,
silent:
args
.
quiet?
,
ignore_non_pypi_packages:
true
end
...
...
@@ -346,7 +348,7 @@ module Homebrew
changed_files
=
[
formula
.
path
]
changed_files
+=
alias_rename
if
alias_rename
.
present?
if
args
.
dry_run?
if
args
.
dry_run?
||
(
args
.
write?
&&
!
args
.
commit?
)
ohai
"try to fork repository with GitHub API"
unless
args
.
no_fork?
ohai
"git fetch --unshallow origin"
if
shallow
ohai
"git add
#{
alias_rename
.
first
}
#{
alias_rename
.
last
}
"
if
alias_rename
.
present?
...
...
@@ -358,24 +360,15 @@ module Homebrew
ohai
"create pull request with GitHub API (base branch:
#{
base_branch
}
)"
else
if
args
.
no_fork?
remote_url
=
Utils
.
popen_read
(
"git remote get-url --push origin"
).
chomp
username
=
formula
.
tap
.
user
else
begin
remote_url
,
username
=
GitHub
.
forked_repo_info!
(
tap_full_name
)
rescue
*
GitHub
.
api_errors
=>
e
formula
.
path
.
atomic_write
(
old_contents
)
odie
"Unable to fork:
#{
e
.
message
}
!"
end
end
safe_system
"git"
,
"fetch"
,
"--unshallow"
,
"origin"
if
shallow
safe_system
"git"
,
"fetch"
,
"--unshallow"
,
"origin"
if
shallow
&&
!
args
.
commit?
safe_system
"git"
,
"add"
,
*
alias_rename
if
alias_rename
.
present?
safe_system
"git"
,
"checkout"
,
"--no-track"
,
"-b"
,
branch
,
origin_branch
safe_system
"git"
,
"checkout"
,
"--no-track"
,
"-b"
,
branch
,
origin_branch
unless
args
.
commit?
safe_system
"git"
,
"commit"
,
"--no-edit"
,
"--verbose"
,
"--message=
#{
formula
.
name
}
#{
new_formula_version
}
"
,
"--"
,
*
changed_files
return
if
args
.
commit?
remote_url
,
username
=
determine_remote_and_username
(
formula
,
tap_full_name
,
old_contents
,
args:
args
)
safe_system
"git"
,
"push"
,
"--set-upstream"
,
remote_url
,
"
#{
branch
}
:
#{
branch
}
"
safe_system
"git"
,
"checkout"
,
"--quiet"
,
previous_branch
pr_message
=
<<~
EOS
...
...
@@ -514,4 +507,19 @@ module Homebrew
FileUtils
.
mv
alias_rename
.
last
,
alias_rename
.
first
if
alias_rename
.
present?
odie
"`brew audit` failed!"
end
def
determine_remote_and_username
(
formula
,
tap_full_name
,
old_contents
,
args
:)
if
args
.
no_fork?
remote_url
=
Utils
.
popen_read
(
"git remote get-url --push origin"
).
chomp
username
=
formula
.
tap
.
user
[
remote_url
,
username
]
else
begin
GitHub
.
forked_repo_info!
(
tap_full_name
)
rescue
*
GitHub
.
api_errors
=>
e
formula
.
path
.
atomic_write
(
old_contents
)
odie
"Unable to fork:
#{
e
.
message
}
!"
end
end
end
end
This diff is collapsed.
Click to expand it.
docs/Manpage.md
+
3
−
1
View file @
88ebbd56
...
...
@@ -841,7 +841,9 @@ nor vice versa. It must use whichever style specification the formula already us
*
`-n`
,
`--dry-run`
:
Print what would be done rather than doing it.
*
`--write`
:
When passed along with
`--dry-run`
, perform a not-so-dry run by making the expected file modifications but not taking any Git actions.
Make the expected file modifications without taking any Git actions.
*
`--commit`
:
When passed with
`--write`
, generate a new commit after writing changes to the formula file.
*
`--no-audit`
:
Don't run
`brew audit`
before opening the PR.
*
`--strict`
:
...
...
This diff is collapsed.
Click to expand it.
manpages/brew.1
+
5
−
1
View file @
88ebbd56
...
...
@@ -1155,7 +1155,11 @@ Print what would be done rather than doing it\.
.
.TP
\fB\-\-write\fR
When passed along with \fB\-\-dry\-run\fR, perform a not\-so\-dry run by making the expected file modifications but not taking any Git actions\.
Make the expected file modifications without taking any Git actions\.
.
.TP
\fB\-\-commit\fR
When passed with \fB\-\-write\fR, generate a new commit after writing changes to the formula file\.
.
.TP
\fB\-\-no\-audit\fR
...
...
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