Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4a7fcc2a
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,发现更多精彩内容 >>
提交
4a7fcc2a
编写于
11月 09, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stop environments for branch after branch removal
上级
5328e3b1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
29 addition
and
9 deletion
+29
-9
app/models/project.rb
app/models/project.rb
+2
-2
app/models/repository.rb
app/models/repository.rb
+13
-2
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+0
-2
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-1
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+12
-1
未找到文件。
app/models/project.rb
浏览文件 @
4a7fcc2a
...
...
@@ -1289,12 +1289,12 @@ class Project < ActiveRecord::Base
end
def
environments_for
(
ref
,
commit:
nil
,
with_tags:
false
)
environments_query
=
with_tags
?
'ref
=? OR tag IS TRUE'
:
'ref=
?'
environments_query
=
with_tags
?
'ref
= ? OR tag IS TRUE'
:
'ref =
?'
environment_ids
=
deployments
.
group
(
:environment_id
)
.
select
(
:environment_id
)
.
where
(
environments_query
,
ref
)
.
where
(
environments_query
,
ref
.
to_s
)
envs
=
environments
.
available
.
where
(
id:
environment_ids
)
...
...
app/models/repository.rb
浏览文件 @
4a7fcc2a
...
...
@@ -203,7 +203,7 @@ class Repository
update_ref!
(
ref
,
newrev
,
oldrev
)
end
after_remove_branch
after_remove_branch
(
user
,
branch_name
)
true
end
...
...
@@ -524,7 +524,12 @@ class Repository
end
# Runs code after an existing branch has been removed.
def
after_remove_branch
def
after_remove_branch
(
user
,
branch_name
)
expire_branch_cache_after_removal
stop_environments_for_branch
(
user
,
branch_name
)
end
def
expire_branch_cache_after_removal
expire_has_visible_content_cache
expire_branch_count_cache
expire_branches_cache
...
...
@@ -1165,4 +1170,10 @@ class Repository
def
repository_event
(
event
,
tags
=
{})
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
path_with_namespace
}.
merge
(
tags
))
end
def
stop_environments_for_branch
(
user
,
branch_name
)
Ci
::
StopEnvironmentService
.
new
(
@project
,
user
)
.
execute
(
branch_name
)
end
end
app/services/delete_branch_service.rb
浏览文件 @
4a7fcc2a
...
...
@@ -21,8 +21,6 @@ class DeleteBranchService < BaseService
return
error
(
'You dont have push access to repo'
,
405
)
end
# StopEnvironmentService
if
repository
.
rm_branch
(
current_user
,
branch_name
)
success
(
'Branch was removed'
)
else
...
...
app/services/git_push_service.rb
浏览文件 @
4a7fcc2a
...
...
@@ -21,7 +21,7 @@ class GitPushService < BaseService
@project
.
repository
.
after_push_commit
(
branch_name
,
params
[
:newrev
])
if
push_remove_branch?
@project
.
repository
.
after_remove_branch
@project
.
repository
.
after_remove_branch
(
current_user
,
branch_name
)
@push_commits
=
[]
elsif
push_to_new_branch?
@project
.
repository
.
after_create_branch
...
...
lib/gitlab/github_import/importer.rb
浏览文件 @
4a7fcc2a
...
...
@@ -111,7 +111,7 @@ module Gitlab
end
end
project
.
repository
.
after_remove_branch
project
.
repository
.
expire_branch_cache_after_removal
end
def
restore_source_branch
(
pull_request
)
...
...
spec/models/repository_spec.rb
浏览文件 @
4a7fcc2a
...
...
@@ -1182,7 +1182,18 @@ describe Repository, models: true do
it
'flushes the visible content cache'
do
expect
(
repository
).
to
receive
(
:expire_has_visible_content_cache
)
repository
.
after_remove_branch
repository
.
after_remove_branch
(
user
,
'master'
)
end
context
'when there is environment with review app available for branch'
do
before
do
create
(
:environment
,
:with_review_app
,
project:
project
)
end
it
'stops environment'
do
expect_any_instance_of
(
Environment
).
to
receive
(
:stop!
)
repository
.
after_remove_branch
(
user
,
'master'
)
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录