Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2f797a14
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f797a14
编写于
4月 14, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip issue comment when its content, updates and attachments are empty.
上级
1abda445
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
39 deletion
+61
-39
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+61
-39
未找到文件。
lib/gitlab/google_code_import/importer.rb
浏览文件 @
2f797a14
...
...
@@ -79,25 +79,13 @@ module Gitlab
author
=
user_map
[
raw_issue
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_issue
[
"published"
]).
to_formatted_s
(
:long
)
body
=
[]
body
<<
"*By
#{
author
}
on
#{
date
}
*"
body
<<
"---"
comments
=
raw_issue
[
"comments"
][
"items"
]
issue_comment
=
comments
.
shift
content
=
format_content
(
issue_comment
[
"content"
])
if
content
.
blank?
content
=
"*(No description has been entered for this issue)*"
end
body
<<
content
content
=
format_content
(
issue_comment
[
"content"
])
attachments
=
format_attachments
(
raw_issue
[
"id"
],
0
,
issue_comment
[
"attachments"
])
if
attachments
.
any?
body
<<
"---"
body
+=
attachments
end
body
=
format_issue_body
(
author
,
date
,
content
,
attachments
)
labels
=
[]
raw_issue
[
"labels"
].
each
do
|
label
|
...
...
@@ -113,7 +101,7 @@ module Gitlab
issue
=
project
.
issues
.
create!
(
title:
raw_issue
[
"title"
],
description:
body
.
join
(
"
\n\n
"
)
,
description:
body
,
author_id:
project
.
creator_id
,
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
)
...
...
@@ -129,35 +117,28 @@ module Gitlab
comments
.
each
do
|
raw_comment
|
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"
])
updates
=
format_updates
(
raw_comment
[
"updates"
])
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
content
=
format_content
(
raw_comment
[
"content"
])
if
content
.
blank?
content
=
"*(No comment has been entered for this change)*"
end
body
<<
content
next
if
content
.
blank?
&&
updates
.
blank?
&&
attachments
.
blank?
updates
=
format_updates
(
raw_comment
[
"updates"
])
if
updates
.
any?
body
<<
"---"
body
+=
updates
end
author
=
user_map
[
raw_comment
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_comment
[
"published"
]).
to_formatted_s
(
:long
)
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
if
attachments
.
any?
body
<<
"---"
body
+=
attachments
end
body
=
format_issue_comment_body
(
raw_comment
[
"id"
],
author
,
date
,
content
,
updates
,
attachments
)
comment
=
issue
.
notes
.
create!
(
issue
.
notes
.
create!
(
project_id:
project
.
id
,
author_id:
project
.
creator_id
,
note:
body
.
join
(
"
\n\n
"
)
note:
body
)
end
end
...
...
@@ -324,6 +305,47 @@ module Gitlab
text
end
.
compact
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录