diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | app/models/repository.rb | 6 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 17 |
3 files changed, 19 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG index 319eb54ec58..dda7e1671b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,9 +12,7 @@ v 8.11.0 (unreleased) - Make fork counter always clickable. !5463 (winniehell) - Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view'. !5368 (Scott Le) - Load project invited groups and members eagerly in `ProjectTeam#fetch_members` - - Make fork counter always clickable !5463 (winniehell) - Page is now properly rendered after commiting the first file and creating the first branch - - Load project invited groups and members eagerly in ProjectTeam#fetch_members - Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska) - Add the `sprockets-es6` gem - Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska) diff --git a/app/models/repository.rb b/app/models/repository.rb index e43fab62b89..9fd8f5ec787 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -990,10 +990,8 @@ class Repository rugged.references.create(ref, newrev) # If repo was empty expire cache - if was_empty - after_create - after_create_branch - end + after_create if was_empty + after_create_branch else # Update head current_head = find_branch(branch).target diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 42c6bfcd09d..5bc1bd9a930 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -447,6 +447,23 @@ describe Repository, models: true do end end + context 'when target branch is different from source branch' do + before do + allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, '']) + end + + it 'expires branch cache' do + expect(repository).not_to receive(:expire_exists_cache) + expect(repository).not_to receive(:expire_root_ref_cache) + expect(repository).not_to receive(:expire_emptiness_caches) + expect(repository).to receive(:expire_branches_cache) + expect(repository).to receive(:expire_has_visible_content_cache) + expect(repository).to receive(:expire_branch_count_cache) + + repository.commit_with_hooks(user, 'new-feature') { sample_commit.id } + end + end + context 'when repository is empty' do before do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, '']) |