Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a951e6f8
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,发现更多精彩内容 >>
提交
a951e6f8
编写于
4月 04, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GitlabSerialize: cause of invalid yaml in some events we migrate to json serialization
上级
8aa5076d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
13 deletion
+36
-13
app/models/event.rb
app/models/event.rb
+2
-2
app/models/event/push_trait.rb
app/models/event/push_trait.rb
+16
-10
app/models/gitlab_serialize.rb
app/models/gitlab_serialize.rb
+17
-0
app/views/dashboard/index.html.haml
app/views/dashboard/index.html.haml
+1
-1
未找到文件。
app/models/event.rb
浏览文件 @
a951e6f8
...
@@ -14,7 +14,7 @@ class Event < ActiveRecord::Base
...
@@ -14,7 +14,7 @@ class Event < ActiveRecord::Base
belongs_to
:project
belongs_to
:project
belongs_to
:target
,
:polymorphic
=>
true
belongs_to
:target
,
:polymorphic
=>
true
serialize
:data
serialize
:data
,
GitlabSerialize
.
new
scope
:recent
,
order
(
"created_at DESC"
)
scope
:recent
,
order
(
"created_at DESC"
)
scope
:code_push
,
where
(
:action
=>
Pushed
)
scope
:code_push
,
where
(
:action
=>
Pushed
)
...
@@ -36,7 +36,7 @@ class Event < ActiveRecord::Base
...
@@ -36,7 +36,7 @@ class Event < ActiveRecord::Base
end
end
def
push?
def
push?
action
==
self
.
class
::
Pushed
action
==
self
.
class
::
Pushed
&&
valid_push?
end
end
def
merged?
def
merged?
...
...
app/models/event/push_trait.rb
浏览文件 @
a951e6f8
module
Event::PushTrait
module
Event::PushTrait
as_trait
do
as_trait
do
def
valid_push?
data
[
"ref"
]
rescue
=>
ex
false
end
def
tag?
def
tag?
data
[
:ref
][
"refs/tags"
]
data
[
"ref"
][
"refs/tags"
]
end
end
def
new_branch?
def
new_branch?
data
[
:before
]
=~
/^00000/
commit_from
=~
/^00000/
end
end
def
new_ref?
def
new_ref?
data
[
:before
]
=~
/^00000/
commit_from
=~
/^00000/
end
end
def
rm_ref?
def
rm_ref?
data
[
:after
]
=~
/^00000/
commit_to
=~
/^00000/
end
end
def
md_ref?
def
md_ref?
...
@@ -21,11 +27,11 @@ module Event::PushTrait
...
@@ -21,11 +27,11 @@ module Event::PushTrait
end
end
def
commit_from
def
commit_from
data
[
:before
]
data
[
"before"
]
end
end
def
commit_to
def
commit_to
data
[
:after
]
data
[
"after"
]
end
end
def
ref_name
def
ref_name
...
@@ -37,16 +43,16 @@ module Event::PushTrait
...
@@ -37,16 +43,16 @@ module Event::PushTrait
end
end
def
branch_name
def
branch_name
@branch_name
||=
data
[
:ref
].
gsub
(
"refs/heads/"
,
""
)
@branch_name
||=
data
[
"ref"
].
gsub
(
"refs/heads/"
,
""
)
end
end
def
tag_name
def
tag_name
@tag_name
||=
data
[
:ref
].
gsub
(
"refs/tags/"
,
""
)
@tag_name
||=
data
[
"ref"
].
gsub
(
"refs/tags/"
,
""
)
end
end
def
commits
def
commits
@commits
||=
data
[
:commits
].
map
do
|
commit
|
@commits
||=
data
[
"commits"
].
map
do
|
commit
|
project
.
commit
(
commit
[
:id
])
project
.
commit
(
commit
[
"id"
])
end
end
end
end
...
...
app/models/gitlab_serialize.rb
0 → 100644
浏览文件 @
a951e6f8
class
GitlabSerialize
# Called to deserialize data to ruby object.
def
load
(
data
)
JSON
.
load
(
data
)
rescue
JSON
::
ParserError
begin
YAML
.
load
(
data
)
rescue
Psych
::
SyntaxError
nil
end
end
# Called to convert from ruby object to serialized data.
def
dump
(
obj
)
JSON
.
dump
(
obj
)
end
end
app/views/dashboard/index.html.haml
浏览文件 @
a951e6f8
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
=
link_to
profile_path
,
:class
=>
"btn"
do
=
link_to
profile_path
,
:class
=>
"btn"
do
Your Profile »
Your Profile »
.span10.left
=
render
"dashboard/projects_feed"
,
:projects
=>
@active_projects
.span10.left
=
render
"dashboard/projects_feed"
,
:projects
=>
@active_projects
-
if
@last_push
-
if
@last_push
&&
@last_push
.
valid_push?
.padded.prepend-top-20
.padded.prepend-top-20
%h5
%h5
%small
Latest push was to the
#{
@last_push
.
branch_name
}
branch of
#{
@last_push
.
project
.
name
}
:
%small
Latest push was to the
#{
@last_push
.
branch_name
}
branch of
#{
@last_push
.
project
.
name
}
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录