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
Kazuhiko Shiozaki
gitlab-ce
Commits
2f797a14
Commit
2f797a14
authored
Apr 14, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip issue comment when its content, updates and attachments are empty.
parent
1abda445
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
39 deletions
+61
-39
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+61
-39
No files found.
lib/gitlab/google_code_import/importer.rb
View file @
2f797a14
...
@@ -79,25 +79,13 @@ module Gitlab
...
@@ -79,25 +79,13 @@ module Gitlab
author
=
user_map
[
raw_issue
[
"author"
][
"name"
]]
author
=
user_map
[
raw_issue
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_issue
[
"published"
]).
to_formatted_s
(
:long
)
date
=
DateTime
.
parse
(
raw_issue
[
"published"
]).
to_formatted_s
(
:long
)
body
=
[]
body
<<
"*By
#{
author
}
on
#{
date
}
*"
body
<<
"---"
comments
=
raw_issue
[
"comments"
][
"items"
]
comments
=
raw_issue
[
"comments"
][
"items"
]
issue_comment
=
comments
.
shift
issue_comment
=
comments
.
shift
content
=
format_content
(
issue_comment
[
"content"
])
content
=
format_content
(
issue_comment
[
"content"
])
if
content
.
blank?
content
=
"*(No description has been entered for this issue)*"
end
body
<<
content
attachments
=
format_attachments
(
raw_issue
[
"id"
],
0
,
issue_comment
[
"attachments"
])
attachments
=
format_attachments
(
raw_issue
[
"id"
],
0
,
issue_comment
[
"attachments"
])
if
attachments
.
any?
body
<<
"---"
body
=
format_issue_body
(
author
,
date
,
content
,
attachments
)
body
+=
attachments
end
labels
=
[]
labels
=
[]
raw_issue
[
"labels"
].
each
do
|
label
|
raw_issue
[
"labels"
].
each
do
|
label
|
...
@@ -113,7 +101,7 @@ module Gitlab
...
@@ -113,7 +101,7 @@ module Gitlab
issue
=
project
.
issues
.
create!
(
issue
=
project
.
issues
.
create!
(
title:
raw_issue
[
"title"
],
title:
raw_issue
[
"title"
],
description:
body
.
join
(
"
\n\n
"
)
,
description:
body
,
author_id:
project
.
creator_id
,
author_id:
project
.
creator_id
,
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
)
)
...
@@ -129,35 +117,28 @@ module Gitlab
...
@@ -129,35 +117,28 @@ module Gitlab
comments
.
each
do
|
raw_comment
|
comments
.
each
do
|
raw_comment
|
next
if
raw_comment
.
has_key?
(
"deletedBy"
)
next
if
raw_comment
.
has_key?
(
"deletedBy"
)
author
=
user_map
[
raw_comment
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_comment
[
"published"
]).
to_formatted_s
(
:long
)
body
=
[]
body
<<
"*Comment
#{
raw_comment
[
"id"
]
}
by
#{
author
}
on
#{
date
}
*"
body
<<
"---"
content
=
format_content
(
raw_comment
[
"content"
])
content
=
format_content
(
raw_comment
[
"content"
])
if
content
.
blank?
content
=
"*(No comment has been entered for this change)*"
end
body
<<
content
updates
=
format_updates
(
raw_comment
[
"updates"
])
updates
=
format_updates
(
raw_comment
[
"updates"
])
if
updates
.
any?
body
<<
"---"
body
+=
updates
end
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
if
attachments
.
any?
body
<<
"---"
body
+=
attachments
end
comment
=
issue
.
notes
.
create!
(
next
if
content
.
blank?
&&
updates
.
blank?
&&
attachments
.
blank?
author
=
user_map
[
raw_comment
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_comment
[
"published"
]).
to_formatted_s
(
:long
)
body
=
format_issue_comment_body
(
raw_comment
[
"id"
],
author
,
date
,
content
,
updates
,
attachments
)
issue
.
notes
.
create!
(
project_id:
project
.
id
,
project_id:
project
.
id
,
author_id:
project
.
creator_id
,
author_id:
project
.
creator_id
,
note:
body
.
join
(
"
\n\n
"
)
note:
body
)
)
end
end
end
end
...
@@ -324,6 +305,47 @@ module Gitlab
...
@@ -324,6 +305,47 @@ module Gitlab
text
text
end
.
compact
end
.
compact
end
end
def
format_issue_comment_body
(
id
,
author
,
date
,
content
,
updates
,
attachments
)
body
=
[]
body
<<
"*Comment
#{
id
}
by
#{
author
}
on
#{
date
}
*"
body
<<
"---"
if
content
.
blank?
content
=
"*(No comment has been entered for this change)*"
end
body
<<
content
if
updates
.
any?
body
<<
"---"
body
+=
updates
end
if
attachments
.
any?
body
<<
"---"
body
+=
attachments
end
body
.
join
(
"
\n\n
"
)
end
def
format_issue_body
(
author
,
date
,
content
,
attachments
)
body
=
[]
body
<<
"*By
#{
author
}
on
#{
date
}
*"
body
<<
"---"
if
content
.
blank?
content
=
"*(No description has been entered for this issue)*"
end
body
<<
content
if
attachments
.
any?
body
<<
"---"
body
+=
attachments
end
body
.
join
(
"
\n\n
"
)
end
end
end
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