summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-11 10:16:03 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-11 10:16:03 +0100
commitbe3d74e096f6b5cb46b5d2440c16383633f1fc06 (patch)
tree351d2afe605fbe2a005315d66d5fba18f031396e
parent4a7fcc2af6eba65dff48b25c81d5925311fa933d (diff)
downloadgitlab-ce-be3d74e096f6b5cb46b5d2440c16383633f1fc06.tar.gz
Do not call environments service in repository model
-rw-r--r--app/models/repository.rb15
-rw-r--r--app/services/git_push_service.rb2
-rw-r--r--lib/gitlab/github_import/importer.rb2
-rw-r--r--spec/models/repository_spec.rb13
4 files changed, 5 insertions, 27 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 38e5cd3faa9..30be7262438 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -203,7 +203,7 @@ class Repository
update_ref!(ref, newrev, oldrev)
end
- after_remove_branch(user, branch_name)
+ after_remove_branch
true
end
@@ -524,12 +524,7 @@ class Repository
end
# Runs code after an existing branch has been removed.
- 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
+ def after_remove_branch
expire_has_visible_content_cache
expire_branch_count_cache
expire_branches_cache
@@ -1170,10 +1165,4 @@ 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
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index ec1c2f61c27..de313095bed 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -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(current_user, branch_name)
+ @project.repository.after_remove_branch
@push_commits = []
elsif push_to_new_branch?
@project.repository.after_create_branch
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index c724577ae89..90cf38a8513 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -111,7 +111,7 @@ module Gitlab
end
end
- project.repository.expire_branch_cache_after_removal
+ project.repository.after_remove_branch
end
def restore_source_branch(pull_request)
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 6d65f6ead12..04b7d19d414 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1182,18 +1182,7 @@ 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(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
+ repository.after_remove_branch
end
end