Skip to content
Snippets Groups Projects
Commit 06570022 authored by Jarka Kadlecova's avatar Jarka Kadlecova
Browse files

Restore has_visible_content? to improve performance (cache)

This method was moved to ::Git but it is not cached there which causes performance problems
parent 1140fcce
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -90,6 +90,12 @@ class Repository
)
end
 
# we need to have this method here because it is not cached in ::Git and
# the method is called multiple times for every request
def has_visible_content?
branch_count > 0
end
def inspect
"#<#{self.class.name}:#{@disk_path}>"
end
Loading
Loading
Loading
Loading
@@ -31,8 +31,8 @@ describe GitGarbageCollectWorker do
 
expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original
expect_any_instance_of(Repository).to receive(:branch_names).and_call_original
expect_any_instance_of(Repository).to receive(:has_visible_content?).and_call_original
expect_any_instance_of(Gitlab::Git::Repository).to receive(:branch_count).and_call_original
expect_any_instance_of(Gitlab::Git::Repository).to receive(:has_visible_content?).and_call_original
 
subject.perform(project.id, :gc, lease_key, lease_uuid)
end
Loading
Loading
@@ -77,8 +77,8 @@ describe GitGarbageCollectWorker do
 
expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original
expect_any_instance_of(Repository).to receive(:branch_names).and_call_original
expect_any_instance_of(Repository).to receive(:has_visible_content?).and_call_original
expect_any_instance_of(Gitlab::Git::Repository).to receive(:branch_count).and_call_original
expect_any_instance_of(Gitlab::Git::Repository).to receive(:has_visible_content?).and_call_original
 
subject.perform(project.id)
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