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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5d106f25
Commit
5d106f25
authored
Apr 24, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the base initiliazer for representations
parent
05255631
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
14 deletions
+11
-14
lib/github/import.rb
lib/github/import.rb
+1
-1
lib/github/representation/branch.rb
lib/github/representation/branch.rb
+4
-5
lib/github/representation/pull_request.rb
lib/github/representation/pull_request.rb
+6
-8
No files found.
lib/github/import.rb
View file @
5d106f25
...
...
@@ -147,7 +147,7 @@ module Github
response
=
Github
::
Client
.
new
(
options
).
get
(
url
,
state: :all
,
sort: :created
,
direction: :asc
)
response
.
body
.
each
do
|
raw
|
pull_request
=
Github
::
Representation
::
PullRequest
.
new
(
project
,
raw
,
options
)
pull_request
=
Github
::
Representation
::
PullRequest
.
new
(
raw
,
options
.
merge
(
project:
project
)
)
merge_request
=
MergeRequest
.
find_or_initialize_by
(
iid:
pull_request
.
iid
,
source_project_id:
project
.
id
)
next
unless
merge_request
.
new_record?
&&
pull_request
.
valid?
...
...
lib/github/representation/branch.rb
View file @
5d106f25
...
...
@@ -3,11 +3,6 @@ module Github
class
Branch
<
Representation
::
Base
attr_reader
:repository
def
initialize
(
repository
,
raw
)
@repository
=
repository
@raw
=
raw
end
def
user
raw
.
dig
(
'user'
,
'login'
)
||
'unknown'
end
...
...
@@ -47,6 +42,10 @@ module Github
def
commit_exists?
repository
.
branch_names_contains
(
sha
).
include?
(
ref
)
end
def
repository
@repository
||=
options
.
fetch
(
:repository
)
end
end
end
end
lib/github/representation/pull_request.rb
View file @
5d106f25
...
...
@@ -6,12 +6,6 @@ module Github
delegate
:user
,
:repo
,
:ref
,
:sha
,
to: :source_branch
,
prefix:
true
delegate
:user
,
:exists?
,
:repo
,
:ref
,
:sha
,
:short_sha
,
to: :target_branch
,
prefix:
true
def
initialize
(
project
,
raw
,
options
)
@project
=
project
@raw
=
raw
@options
=
options
end
def
source_project
project
end
...
...
@@ -54,8 +48,12 @@ module Github
private
def
project
@project
||=
options
.
fetch
(
:project
)
end
def
source_branch
@source_branch
||=
Representation
::
Branch
.
new
(
project
.
repository
,
raw
[
'head'
]
)
@source_branch
||=
Representation
::
Branch
.
new
(
raw
[
'head'
],
repository:
project
.
repository
)
end
def
source_branch_name_prefixed
...
...
@@ -63,7 +61,7 @@ module Github
end
def
target_branch
@target_branch
||=
Representation
::
Branch
.
new
(
project
.
repository
,
raw
[
'base'
]
)
@target_branch
||=
Representation
::
Branch
.
new
(
raw
[
'base'
],
repository:
project
.
repository
)
end
def
target_branch_name_prefixed
...
...
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