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
dd71f388
Unverified
Commit
dd71f388
authored
4 years ago
by
Dawid Dziurla
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8368 from SeekingMeaning/github/forked_repo_info
utils/github: add `forked_repo_info!`
parents
778bd543
ffcf0686
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/bump-formula-pr.rb
+6
-22
6 additions, 22 deletions
Library/Homebrew/dev-cmd/bump-formula-pr.rb
Library/Homebrew/utils/github.rb
+17
-0
17 additions, 0 deletions
Library/Homebrew/utils/github.rb
with
23 additions
and
22 deletions
Library/Homebrew/dev-cmd/bump-formula-pr.rb
+
6
−
22
View file @
dd71f388
...
...
@@ -362,7 +362,12 @@ module Homebrew
remote_url
=
Utils
.
popen_read
(
"git remote get-url --push origin"
).
chomp
username
=
formula
.
tap
.
user
else
remote_url
,
username
=
forked_repo_info
(
formula
,
tap_full_name
,
old_contents
)
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
...
...
@@ -445,27 +450,6 @@ module Homebrew
[
resource
.
fetch
,
forced_version
]
end
def
forked_repo_info
(
formula
,
tap_full_name
,
old_contents
)
response
=
GitHub
.
create_fork
(
tap_full_name
)
rescue
GitHub
::
AuthenticationFailedError
,
*
GitHub
.
api_errors
=>
e
formula
.
path
.
atomic_write
(
old_contents
)
odie
"Unable to fork:
#{
e
.
message
}
!"
else
# GitHub API responds immediately but fork takes a few seconds to be ready.
sleep
1
until
GitHub
.
check_fork_exists
(
tap_full_name
)
remote_url
=
if
system
(
"git"
,
"config"
,
"--local"
,
"--get-regexp"
,
"remote
\.
.*
\.
url"
,
"git@github.com:.*"
)
response
.
fetch
(
"ssh_url"
)
else
url
=
response
.
fetch
(
"clone_url"
)
if
(
api_token
=
Homebrew
::
EnvConfig
.
github_api_token
)
url
.
gsub!
(
%r{^https://github
\.
com/}
,
"https://
#{
api_token
}
@github.com/"
)
end
url
end
username
=
response
.
fetch
(
"owner"
).
fetch
(
"login"
)
[
remote_url
,
username
]
end
def
formula_version
(
formula
,
spec
,
contents
=
nil
)
name
=
formula
.
name
path
=
formula
.
path
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/utils/github.rb
+
17
−
0
View file @
dd71f388
...
...
@@ -603,4 +603,21 @@ module GitHub
EOS
end
end
def
forked_repo_info!
(
tap_full_name
)
response
=
GitHub
.
create_fork
(
tap_full_name
)
# GitHub API responds immediately but fork takes a few seconds to be ready.
sleep
1
until
GitHub
.
check_fork_exists
(
tap_full_name
)
remote_url
=
if
system
(
"git"
,
"config"
,
"--local"
,
"--get-regexp"
,
"remote
\.
.*
\.
url"
,
"git@github.com:.*"
)
response
.
fetch
(
"ssh_url"
)
else
url
=
response
.
fetch
(
"clone_url"
)
if
(
api_token
=
Homebrew
::
EnvConfig
.
github_api_token
)
url
.
gsub!
(
%r{^https://github
\.
com/}
,
"https://
#{
api_token
}
@github.com/"
)
end
url
end
username
=
response
.
fetch
(
"owner"
).
fetch
(
"login"
)
[
remote_url
,
username
]
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