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
a55e1501
Commit
a55e1501
authored
Oct 05, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set `label_ids` and `assignee_ids` after the initial `save!`.
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f96b4f41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
20 deletions
+42
-20
lib/github/import.rb
lib/github/import.rb
+12
-6
lib/github/representation/issuable.rb
lib/github/representation/issuable.rb
+8
-6
lib/github/representation/issue.rb
lib/github/representation/issue.rb
+12
-8
lib/github/representation/pull_request.rb
lib/github/representation/pull_request.rb
+10
-0
No files found.
lib/github/import.rb
View file @
a55e1501
...
...
@@ -99,7 +99,7 @@ module Github
label
.
color
=
representation
.
color
end
cached
[
:label_ids
][
label
.
title
]
=
label
.
id
cached
[
:label_ids
][
representation
.
title
]
=
label
.
id
rescue
=>
e
error
(
:label
,
representation
.
url
,
e
.
message
)
end
...
...
@@ -211,11 +211,11 @@ module Github
# for both features, like manipulating assignees, labels
# and milestones, are provided within the Issues API.
if
representation
.
pull_request?
return
unless
representation
.
has_
labels?
||
representation
.
has_comments?
return
unless
representation
.
labels?
||
representation
.
has_comments?
merge_request
=
MergeRequest
.
find_by!
(
target_project_id:
project
.
id
,
iid:
representation
.
iid
)
if
representation
.
has_
labels?
if
representation
.
labels?
merge_request
.
update_attribute
(
:label_ids
,
label_ids
(
representation
.
labels
))
end
...
...
@@ -230,14 +230,16 @@ module Github
issue
.
title
=
representation
.
title
issue
.
description
=
format_description
(
representation
.
description
,
representation
.
author
)
issue
.
state
=
representation
.
state
issue
.
label_ids
=
label_ids
(
representation
.
labels
)
issue
.
milestone_id
=
milestone_id
(
representation
.
milestone
)
issue
.
author_id
=
author_id
issue
.
assignee_ids
=
[
user_id
(
representation
.
assignee
)]
issue
.
created_at
=
representation
.
created_at
issue
.
updated_at
=
representation
.
updated_at
issue
.
save!
(
validate:
false
)
issue
.
update
(
label_ids:
label_ids
(
representation
.
labels
),
assignee_ids:
assignee_ids
(
representation
.
assignees
))
fetch_comments_conditionally
(
issue
,
representation
)
end
rescue
=>
e
...
...
@@ -310,7 +312,11 @@ module Github
end
def
label_ids
(
labels
)
labels
.
map
{
|
attrs
|
cached
[
:label_ids
][
attrs
.
fetch
(
'name'
)]
}.
compact
labels
.
map
{
|
label
|
cached
[
:label_ids
][
label
.
title
]
}.
compact
end
def
assignee_ids
(
assignees
)
assignees
.
map
{
|
assignee
|
user_id
(
assignee
)
}.
compact
end
def
milestone_id
(
milestone
)
...
...
lib/github/representation/issuable.rb
View file @
a55e1501
...
...
@@ -23,14 +23,16 @@ module Github
@author
||=
Github
::
Representation
::
User
.
new
(
raw
[
'user'
],
options
)
end
def
assignee
return
unless
assigned?
@assignee
||=
Github
::
Representation
::
User
.
new
(
raw
[
'assignee'
],
options
)
def
labels?
raw
[
'labels'
].
any?
end
def
assigned?
raw
[
'assignee'
].
present?
def
labels
return
[]
unless
labels?
@labels
||=
raw
[
'labels'
].
map
do
|
label
|
Github
::
Representation
::
Label
.
new
(
label
,
options
)
end
end
end
end
...
...
lib/github/representation/issue.rb
View file @
a55e1501
module
Github
module
Representation
class
Issue
<
Representation
::
Issuable
def
labels
raw
[
'labels'
]
end
def
state
raw
[
'state'
]
==
'closed'
?
'closed'
:
'opened'
end
...
...
@@ -13,13 +9,21 @@ module Github
raw
[
'comments'
]
>
0
end
def
has_labels?
labels
.
count
>
0
end
def
pull_request?
raw
[
'pull_request'
].
present?
end
def
assigned?
raw
[
'assignees'
].
present?
end
def
assignees
return
[]
unless
assigned?
@assignees
||=
raw
[
'assignees'
].
map
do
|
user
|
Github
::
Representation
::
User
.
new
(
user
,
options
)
end
end
end
end
end
lib/github/representation/pull_request.rb
View file @
a55e1501
...
...
@@ -37,6 +37,16 @@ module Github
source_branch
.
valid?
&&
target_branch
.
valid?
end
def
assigned?
raw
[
'assignee'
].
present?
end
def
assignee
return
unless
assigned?
@assignee
||=
Github
::
Representation
::
User
.
new
(
raw
[
'assignee'
],
options
)
end
private
def
project
...
...
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