Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c8102d93
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,体验更适合开发者的 AI 搜索 >>
提交
c8102d93
编写于
2月 01, 2016
作者:
G
Grzegorz Bizon
提交者:
Grzegorz Bizon
2月 19, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add build eraseable feature implementation
上级
89b18120
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
90 addition
and
11 deletion
+90
-11
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+4
-4
app/models/ci/build/eraseable.rb
app/models/ci/build/eraseable.rb
+18
-3
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+5
-4
config/routes.rb
config/routes.rb
+1
-0
spec/models/ci/build/eraseable_spec.rb
spec/models/ci/build/eraseable_spec.rb
+62
-0
未找到文件。
app/controllers/projects/builds_controller.rb
浏览文件 @
c8102d93
...
...
@@ -56,10 +56,10 @@ class Projects::BuildsController < Projects::ApplicationController
render
json:
@build
.
to_json
(
only:
[
:status
,
:id
,
:sha
,
:coverage
],
methods: :sha
)
end
def
destroy
@build
.
destroy
redirect_to
namespace_project_build
s_path
(
project
.
namespace
,
project
),
notice:
"Build #
#{
@build
.
id
}
has been sucessfully
remov
ed!"
def
erase
@build
.
erase!
redirect_to
namespace_project_build
_path
(
project
.
namespace
,
project
,
@build
),
notice:
"Build #
#{
@build
.
id
}
has been sucessfully
eras
ed!"
end
private
...
...
app/models/ci/build/eraseable.rb
浏览文件 @
c8102d93
...
...
@@ -4,11 +4,26 @@ module Ci
include
ActiveSupport
::
Concern
def
erase!
raise
NotImplementedError
raise
StandardError
,
'Build not eraseable!'
unless
eraseable?
remove_artifacts_file!
remove_artifacts_metadata!
erase_trace!
end
def
erased?
raise
NotImpementedError
def
eraseable?
artifacts_file
.
exists?
||
File
.
file?
(
path_to_trace
)
end
def
erase_url
if
eraseable?
erase_namespace_project_build_path
(
project
.
namespace
,
project
,
self
)
end
end
private
def
erase_trace!
File
.
truncate
(
path_to_trace
,
0
)
if
File
.
file?
(
path_to_trace
)
end
end
end
...
...
app/views/projects/builds/show.html.haml
浏览文件 @
c8102d93
...
...
@@ -113,10 +113,11 @@
-
elsif
@build
.
retry_url
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
''
,
class:
'btn btn-sm btn-danger'
,
method: :delete
,
data:
{
confirm:
'Are you sure you want to remove this?'
}
do
=
icon
(
'remove'
)
Remove
-
if
@build
.
eraseable?
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :put
,
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
=
icon
(
'eraser'
)
Erase
.clearfix
-
if
@build
.
duration
...
...
config/routes.rb
浏览文件 @
c8102d93
...
...
@@ -617,6 +617,7 @@ Rails.application.routes.draw do
get
:status
post
:cancel
post
:retry
put
:erase
end
resource
:artifacts
,
only:
[]
do
...
...
spec/models/ci/build/eraseable_spec.rb
0 → 100644
浏览文件 @
c8102d93
require
'spec_helper'
describe
Ci
::
Build
::
Eraseable
,
models:
true
do
context
'build is not eraseable'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
describe
'#erase!'
do
it
{
expect
{
build
.
erase!
}.
to
raise_error
(
StandardError
,
/Build not eraseable!/
)}
end
describe
'#eraseable?'
do
subject
{
build
.
eraseable?
}
it
{
is_expected
.
to
eq
false
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'build is eraseable'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
)
}
describe
'#erase!'
do
before
{
build
.
erase!
}
it
'should remove artifact file'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
end
it
'should remove artifact metadata file'
do
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
it
'should erase build trace in trace file'
do
expect
(
File
.
zero?
(
build
.
path_to_trace
)).
to
eq
true
end
end
describe
'#eraseable?'
do
subject
{
build
.
eraseable?
}
it
{
is_expected
.
to
eq
true
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_truthy
}
end
context
'metadata and build trace are not available'
do
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
before
{
build
.
remove_artifacts_metadata!
}
describe
'#erase!'
do
it
'should not raise error'
do
expect
{
build
.
erase!
}.
to_not
raise_error
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录