Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
7a34c799
Commit
7a34c799
authored
Jun 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Listing GH Webhooks doesn't stop import process for non GH admin users
parent
71ecd8c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+18
-5
No files found.
lib/gitlab/github_import/importer.rb
View file @
7a34c799
...
@@ -66,8 +66,7 @@ module Gitlab
...
@@ -66,8 +66,7 @@ module Gitlab
end
end
def
import_pull_requests
def
import_pull_requests
hooks
=
client
.
hooks
(
repo
).
map
{
|
raw
|
HookFormatter
.
new
(
raw
)
}.
select
(
&
:valid?
)
disable_webhooks
disable_webhooks
(
hooks
)
pull_requests
=
client
.
pull_requests
(
repo
,
state: :all
,
sort: :created
,
direction: :asc
,
per_page:
100
)
pull_requests
=
client
.
pull_requests
(
repo
,
state: :all
,
sort: :created
,
direction: :asc
,
per_page:
100
)
pull_requests
=
pull_requests
.
map
{
|
raw
|
PullRequestFormatter
.
new
(
project
,
raw
)
}.
select
(
&
:valid?
)
pull_requests
=
pull_requests
.
map
{
|
raw
|
PullRequestFormatter
.
new
(
project
,
raw
)
}.
select
(
&
:valid?
)
...
@@ -90,14 +89,14 @@ module Gitlab
...
@@ -90,14 +89,14 @@ module Gitlab
raise
Projects
::
ImportService
::
Error
,
e
.
message
raise
Projects
::
ImportService
::
Error
,
e
.
message
ensure
ensure
clean_up_restored_branches
(
branches_removed
)
clean_up_restored_branches
(
branches_removed
)
clean_up_disabled_webhooks
(
hooks
)
clean_up_disabled_webhooks
end
end
def
disable_webhooks
(
hooks
)
def
disable_webhooks
update_webhooks
(
hooks
,
active:
false
)
update_webhooks
(
hooks
,
active:
false
)
end
end
def
clean_up_disabled_webhooks
(
hooks
)
def
clean_up_disabled_webhooks
update_webhooks
(
hooks
,
active:
true
)
update_webhooks
(
hooks
,
active:
true
)
end
end
...
@@ -107,6 +106,20 @@ module Gitlab
...
@@ -107,6 +106,20 @@ module Gitlab
end
end
end
end
def
hooks
@hooks
||=
begin
client
.
hooks
(
repo
).
map
{
|
raw
|
HookFormatter
.
new
(
raw
)
}.
select
(
&
:valid?
)
# The GitHub Repository Webhooks API returns 404 for users
# without admin access to the repository when listing hooks.
# In this case we just want to return gracefully instead of
# spitting out an error and stop the import process.
rescue
Octokit
::
NotFound
[]
end
end
def
restore_branches
(
branches
)
def
restore_branches
(
branches
)
branches
.
each
do
|
name
,
sha
|
branches
.
each
do
|
name
,
sha
|
client
.
create_ref
(
repo
,
"refs/heads/
#{
name
}
"
,
sha
)
client
.
create_ref
(
repo
,
"refs/heads/
#{
name
}
"
,
sha
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment