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
415c3604
Commit
415c3604
authored
4 years ago
by
Jonathan Chang
Browse files
Options
Downloads
Patches
Plain Diff
dev-cmd/pr-pull: use GitHub API to get PR commits
parent
1d778807
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/pr-pull.rb
+8
-10
8 additions, 10 deletions
Library/Homebrew/dev-cmd/pr-pull.rb
Library/Homebrew/test/utils/github_spec.rb
+7
-0
7 additions, 0 deletions
Library/Homebrew/test/utils/github_spec.rb
Library/Homebrew/utils/github.rb
+4
-0
4 additions, 0 deletions
Library/Homebrew/utils/github.rb
with
19 additions
and
10 deletions
Library/Homebrew/dev-cmd/pr-pull.rb
+
8
−
10
View file @
415c3604
...
...
@@ -275,22 +275,20 @@ module Homebrew
raise
end
def
cherry_pick_pr!
(
pr
,
args
:,
path:
"."
)
def
cherry_pick_pr!
(
user
,
repo
,
pr
,
args
:,
path:
"."
)
if
args
.
dry_run?
puts
<<~
EOS
git fetch --force origin +refs/pull/
#{
pr
}
/head
git merge-base HEAD FETCH_HEAD
git cherry-pick --ff --allow-empty $merge_base..FETCH_HEAD
EOS
else
safe_system
"git"
,
"-C"
,
path
,
"fetch"
,
"--quiet"
,
"--force"
,
"origin"
,
"+refs/pull/
#{
pr
}
/head"
merge_base
=
Utils
.
popen_read
(
"git"
,
"-C"
,
path
,
"merge-base"
,
"HEAD"
,
"FETCH_HEAD"
).
strip
commit_count
=
Utils
.
popen_read
(
"git"
,
"-C"
,
path
,
"rev-list"
,
"
#{
merge_base
}
..FETCH_HEAD"
).
lines
.
count
ohai
"Using
#{
commit_count
}
commit
#{
"s"
unless
commit_count
==
1
}
from #
#{
pr
}
"
Utils
::
Git
.
cherry_pick!
(
path
,
"--ff"
,
"--allow-empty"
,
"
#{
merge_base
}
..FETCH_HEAD"
,
verbose:
args
.
verbose?
,
resolve:
args
.
resolve?
)
return
end
commits
=
GitHub
.
pull_request_commits
(
user
,
repo
,
pr
)
safe_system
"git"
,
"-C"
,
path
,
"fetch"
,
"--quiet"
,
"--force"
,
"origin"
,
commits
.
last
ohai
"Using
#{
commits
.
count
}
commit
#{
"s"
unless
commits
.
count
==
1
}
from #
#{
pr
}
"
Utils
::
Git
.
cherry_pick!
(
path
,
"--ff"
,
"--allow-empty"
,
*
commits
,
verbose:
args
.
verbose?
,
resolve:
args
.
resolve?
)
end
def
check_branch
(
path
,
ref
,
args
:)
...
...
@@ -391,7 +389,7 @@ module Homebrew
Dir
.
mktmpdir
pr
do
|
dir
|
cd
dir
do
original_commit
=
Utils
.
popen_read
(
"git"
,
"-C"
,
tap
.
path
,
"rev-parse"
,
"HEAD"
).
chomp
cherry_pick_pr!
(
pr
,
path:
tap
.
path
,
args:
args
)
cherry_pick_pr!
(
user
,
repo
,
pr
,
path:
tap
.
path
,
args:
args
)
autosquash!
(
original_commit
,
path:
tap
.
path
,
args:
args
)
if
args
.
autosquash?
signoff!
(
pr
,
tap:
tap
,
args:
args
)
unless
args
.
clean?
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/utils/github_spec.rb
+
7
−
0
View file @
415c3604
...
...
@@ -75,4 +75,11 @@ describe GitHub do
expect
(
url
).
to
eq
(
"https://api.github.com/repos/Homebrew/homebrew-core/actions/artifacts/3557392/zip"
)
end
end
describe
"::pull_request_commits"
,
:needs_network
do
it
"gets the correct commits hashes for a pull request"
do
hashes
=
%w[188606a4a9587365d930b02c98ad6857b1d00150 25a71fe1ea1558415d6496d23834dc70778ddee5]
expect
(
subject
.
pull_request_commits
(
"Homebrew"
,
"legacy-homebrew"
,
50678
)).
to
eq
(
hashes
)
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/utils/github.rb
+
4
−
0
View file @
415c3604
...
...
@@ -747,4 +747,8 @@ module GitHub
end
end
end
def
pull_request_commits
(
user
,
repo
,
pr
)
open_api
(
url_to
(
"repos"
,
user
,
repo
,
"pulls"
,
pr
,
"commits?per_page=100"
)).
map
{
|
c
|
c
[
"sha"
]
}
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