Skip to content
Snippets Groups Projects
Commit be3d74e0 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Do not call environments service in repository model

parent 4a7fcc2a
No related branches found
No related tags found
No related merge requests found
Loading
@@ -203,7 +203,7 @@ class Repository
Loading
@@ -203,7 +203,7 @@ class Repository
update_ref!(ref, newrev, oldrev) update_ref!(ref, newrev, oldrev)
end end
   
after_remove_branch(user, branch_name) after_remove_branch
true true
end end
   
Loading
@@ -524,12 +524,7 @@ class Repository
Loading
@@ -524,12 +524,7 @@ class Repository
end end
   
# Runs code after an existing branch has been removed. # Runs code after an existing branch has been removed.
def after_remove_branch(user, branch_name) def after_remove_branch
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_has_visible_content_cache
expire_branch_count_cache expire_branch_count_cache
expire_branches_cache expire_branches_cache
Loading
@@ -1170,10 +1165,4 @@ class Repository
Loading
@@ -1170,10 +1165,4 @@ class Repository
def repository_event(event, tags = {}) def repository_event(event, tags = {})
Gitlab::Metrics.add_event(event, { path: path_with_namespace }.merge(tags)) Gitlab::Metrics.add_event(event, { path: path_with_namespace }.merge(tags))
end end
def stop_environments_for_branch(user, branch_name)
Ci::StopEnvironmentService
.new(@project, user)
.execute(branch_name)
end
end end
Loading
@@ -21,7 +21,7 @@ class GitPushService < BaseService
Loading
@@ -21,7 +21,7 @@ class GitPushService < BaseService
@project.repository.after_push_commit(branch_name, params[:newrev]) @project.repository.after_push_commit(branch_name, params[:newrev])
   
if push_remove_branch? if push_remove_branch?
@project.repository.after_remove_branch(current_user, branch_name) @project.repository.after_remove_branch
@push_commits = [] @push_commits = []
elsif push_to_new_branch? elsif push_to_new_branch?
@project.repository.after_create_branch @project.repository.after_create_branch
Loading
Loading
Loading
@@ -111,7 +111,7 @@ module Gitlab
Loading
@@ -111,7 +111,7 @@ module Gitlab
end end
end end
   
project.repository.expire_branch_cache_after_removal project.repository.after_remove_branch
end end
   
def restore_source_branch(pull_request) def restore_source_branch(pull_request)
Loading
Loading
Loading
@@ -1182,18 +1182,7 @@ describe Repository, models: true do
Loading
@@ -1182,18 +1182,7 @@ describe Repository, models: true do
it 'flushes the visible content cache' do it 'flushes the visible content cache' do
expect(repository).to receive(:expire_has_visible_content_cache) expect(repository).to receive(:expire_has_visible_content_cache)
   
repository.after_remove_branch(user, 'master') repository.after_remove_branch
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
end end
   
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment