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
Léo-Paul Géneau
gitlab-ce
Commits
a7cb336e
Commit
a7cb336e
authored
Apr 19, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use while instead of loop/break
parent
18144530
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lib/github/import.rb
lib/github/import.rb
+10
-12
No files found.
lib/github/import.rb
View file @
a7cb336e
...
@@ -54,14 +54,12 @@ module Github
...
@@ -54,14 +54,12 @@ module Github
# Fetch labels
# Fetch labels
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/labels"
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/labels"
loop
do
while
url
response
=
Github
::
Client
.
new
(
options
).
get
(
url
)
response
=
Github
::
Client
.
new
(
options
).
get
(
url
)
response
.
body
.
each
do
|
raw
|
response
.
body
.
each
do
|
raw
|
begin
begin
label
=
Github
::
Representation
::
Label
.
new
(
raw
)
label
=
Github
::
Representation
::
Label
.
new
(
raw
)
# TODO: we should take group labels in account
next
if
project
.
labels
.
where
(
title:
label
.
title
).
exists?
next
if
project
.
labels
.
where
(
title:
label
.
title
).
exists?
project
.
labels
.
create!
(
title:
label
.
title
,
color:
label
.
color
)
project
.
labels
.
create!
(
title:
label
.
title
,
color:
label
.
color
)
...
@@ -70,7 +68,7 @@ module Github
...
@@ -70,7 +68,7 @@ module Github
end
end
end
end
break
unless
url
=
response
.
rels
[
:next
]
url
=
response
.
rels
[
:next
]
end
end
# Cache labels
# Cache labels
...
@@ -82,7 +80,7 @@ module Github
...
@@ -82,7 +80,7 @@ module Github
# Fetch milestones
# Fetch milestones
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/milestones"
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/milestones"
loop
do
while
url
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
)
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
)
response
.
body
.
each
do
|
raw
|
response
.
body
.
each
do
|
raw
|
...
@@ -104,13 +102,13 @@ module Github
...
@@ -104,13 +102,13 @@ module Github
end
end
end
end
break
unless
url
=
response
.
rels
[
:next
]
url
=
response
.
rels
[
:next
]
end
end
# Fetch pull requests
# Fetch pull requests
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/pulls"
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/pulls"
loop
do
while
url
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
,
sort: :created
,
direction: :asc
)
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
,
sort: :created
,
direction: :asc
)
response
.
body
.
each
do
|
raw
|
response
.
body
.
each
do
|
raw
|
...
@@ -156,13 +154,13 @@ module Github
...
@@ -156,13 +154,13 @@ module Github
end
end
end
end
break
unless
url
=
response
.
rels
[
:next
]
url
=
response
.
rels
[
:next
]
end
end
# Fetch issues
# Fetch issues
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/issues"
url
=
"/repos/
#{
owner
}
/
#{
repo
}
/issues"
loop
do
while
url
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
,
sort: :created
,
direction: :asc
)
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
,
sort: :created
,
direction: :asc
)
response
.
body
.
each
do
|
raw
|
response
.
body
.
each
do
|
raw
|
...
@@ -207,7 +205,7 @@ module Github
...
@@ -207,7 +205,7 @@ module Github
end
end
end
end
break
unless
url
=
response
.
rels
[
:next
]
url
=
response
.
rels
[
:next
]
end
end
repository
.
expire_content_cache
repository
.
expire_content_cache
...
@@ -218,7 +216,7 @@ module Github
...
@@ -218,7 +216,7 @@ module Github
private
private
def
fetch_comments
(
noteable
,
type
,
url
)
def
fetch_comments
(
noteable
,
type
,
url
)
loop
do
while
url
comments
=
Github
::
Client
.
new
(
options
).
get
(
url
)
comments
=
Github
::
Client
.
new
(
options
).
get
(
url
)
ActiveRecord
::
Base
.
no_touching
do
ActiveRecord
::
Base
.
no_touching
do
...
@@ -244,7 +242,7 @@ module Github
...
@@ -244,7 +242,7 @@ module Github
end
end
end
end
break
unless
url
=
comments
.
rels
[
:next
]
url
=
comments
.
rels
[
:next
]
end
end
end
end
...
...
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