Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c903f23f
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,发现更多精彩内容 >>
未验证
提交
c903f23f
编写于
11月 13, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split complex methods in GoogleCodeImport::Importer
Signed-off-by:
N
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
上级
ea6a78ef
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
46 deletion
+47
-46
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+47
-46
未找到文件。
lib/gitlab/google_code_import/importer.rb
浏览文件 @
c903f23f
...
...
@@ -30,7 +30,7 @@ module Gitlab
def
user_map
@user_map
||=
begin
user_map
=
Hash
.
new
do
|
hash
,
user
|
user_map
=
Hash
.
new
do
|
hash
,
user
|
# Replace ... by \.\.\., so `johnsm...@gmail.com` isn't autolinked.
Client
.
mask_email
(
user
).
sub
(
"..."
,
"
\\
.
\\
.
\\
."
)
end
...
...
@@ -76,18 +76,7 @@ module Gitlab
attachments
=
format_attachments
(
raw_issue
[
"id"
],
0
,
issue_comment
[
"attachments"
])
body
=
format_issue_body
(
author
,
date
,
content
,
attachments
)
labels
=
[]
raw_issue
[
"labels"
].
each
do
|
label
|
name
=
nice_label_name
(
label
)
labels
<<
name
unless
@known_labels
.
include?
(
name
)
create_label
(
name
)
@known_labels
<<
name
end
end
labels
<<
nice_status_name
(
raw_issue
[
"status"
])
labels
=
import_issue_labels
(
raw_issue
)
assignee_id
=
nil
if
raw_issue
.
has_key?
(
"owner"
)
...
...
@@ -110,6 +99,7 @@ module Gitlab
assignee_id:
assignee_id
,
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
)
issue
.
add_labels_by_names
(
labels
)
if
issue
.
iid
!=
raw_issue
[
"id"
]
...
...
@@ -120,6 +110,23 @@ module Gitlab
end
end
def
import_issue_labels
(
raw_issue
)
labels
=
[]
raw_issue
[
"labels"
].
each
do
|
label
|
name
=
nice_label_name
(
label
)
labels
<<
name
unless
@known_labels
.
include?
(
name
)
create_label
(
name
)
@known_labels
<<
name
end
end
labels
<<
nice_status_name
(
raw_issue
[
"status"
])
labels
end
def
import_issue_comments
(
issue
,
comments
)
Note
.
transaction
do
while
raw_comment
=
comments
.
shift
...
...
@@ -172,7 +179,7 @@ module Gitlab
"#5cb85c"
when
"Status: Started"
"#8e44ad"
when
"Priority: Critical"
"#ffcfcf"
when
"Priority: High"
...
...
@@ -181,7 +188,7 @@ module Gitlab
"#fff5cc"
when
"Priority: Low"
"#cfe9ff"
when
"Type: Defect"
"#d9534f"
when
"Type: Enhancement"
...
...
@@ -249,8 +256,8 @@ module Gitlab
end
if
raw_updates
.
has_key?
(
"cc"
)
cc
=
raw_updates
[
"cc"
].
map
do
|
l
|
deleted
=
l
.
start_with?
(
"-"
)
cc
=
raw_updates
[
"cc"
].
map
do
|
l
|
deleted
=
l
.
start_with?
(
"-"
)
l
=
l
[
1
..-
1
]
if
deleted
l
=
user_map
[
l
]
l
=
"~~
#{
l
}
~~"
if
deleted
...
...
@@ -261,8 +268,8 @@ module Gitlab
end
if
raw_updates
.
has_key?
(
"labels"
)
labels
=
raw_updates
[
"labels"
].
map
do
|
l
|
deleted
=
l
.
start_with?
(
"-"
)
labels
=
raw_updates
[
"labels"
].
map
do
|
l
|
deleted
=
l
.
start_with?
(
"-"
)
l
=
l
[
1
..-
1
]
if
deleted
l
=
nice_label_name
(
l
)
l
=
"~~
#{
l
}
~~"
if
deleted
...
...
@@ -278,45 +285,39 @@ module Gitlab
if
raw_updates
.
has_key?
(
"blockedOn"
)
blocked_ons
=
raw_updates
[
"blockedOn"
].
map
do
|
raw_blocked_on
|
name
,
id
=
raw_blocked_on
.
split
(
":"
,
2
)
deleted
=
name
.
start_with?
(
"-"
)
name
=
name
[
1
..-
1
]
if
deleted
text
=
if
name
==
project
.
import_source
"#
#{
id
}
"
else
"
#{
project
.
namespace
.
path
}
/
#{
name
}
#
#{
id
}
"
end
text
=
"~~
#{
text
}
~~"
if
deleted
text
format_blocking_updates
(
raw_blocked_on
)
end
updates
<<
"*Blocked on:
#{
blocked_ons
.
join
(
", "
)
}
*"
end
if
raw_updates
.
has_key?
(
"blocking"
)
blockings
=
raw_updates
[
"blocking"
].
map
do
|
raw_blocked_on
|
name
,
id
=
raw_blocked_on
.
split
(
":"
,
2
)
deleted
=
name
.
start_with?
(
"-"
)
name
=
name
[
1
..-
1
]
if
deleted
text
=
if
name
==
project
.
import_source
"#
#{
id
}
"
else
"
#{
project
.
namespace
.
path
}
/
#{
name
}
#
#{
id
}
"
end
text
=
"~~
#{
text
}
~~"
if
deleted
text
format_blocking_updates
(
raw_blocked_on
)
end
updates
<<
"*Blocking:
#{
blockings
.
join
(
", "
)
}
*"
end
updates
end
def
format_blocking_updates
(
raw_blocked_on
)
name
,
id
=
raw_blocked_on
.
split
(
":"
,
2
)
deleted
=
name
.
start_with?
(
"-"
)
name
=
name
[
1
..-
1
]
if
deleted
text
=
if
name
==
project
.
import_source
"#
#{
id
}
"
else
"
#{
project
.
namespace
.
path
}
/
#{
name
}
#
#{
id
}
"
end
text
=
"~~
#{
text
}
~~"
if
deleted
text
end
def
format_attachments
(
issue_id
,
comment_id
,
raw_attachments
)
return
[]
unless
raw_attachments
...
...
@@ -325,7 +326,7 @@ module Gitlab
filename
=
attachment
[
"fileName"
]
link
=
"https://storage.googleapis.com/google-code-attachments/
#{
@repo
.
name
}
/issue-
#{
issue_id
}
/comment-
#{
comment_id
}
/
#{
filename
}
"
text
=
"[
#{
filename
}
](
#{
link
}
)"
text
=
"!
#{
text
}
"
if
filename
=~
/\.(png|jpg|jpeg|gif|bmp|tiff)\z/i
text
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录