diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-27 11:15:58 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-27 11:15:58 +0000 |
commit | 0d2861f3c98dcbb2c76aa1184cc8ddaed5d2eabf (patch) | |
tree | 1486c734730c3337243d7bcd4a76a23e7128ba41 | |
parent | f4804d5bb4b37f4de80e4a2e248f0958c615b618 (diff) | |
parent | 2c0f8eb1cc844561c294a3d4fe9388c6c7ed2acf (diff) | |
download | gitlab-ce-0d2861f3c98dcbb2c76aa1184cc8ddaed5d2eabf.tar.gz |
Merge branch '20025-empty-project-does-not-show-repository' into 'master'
Resolve "Empty project page does not show Repository section on navbar after creating first branch/file"
This MR aims to fix the rendering of the project's page after creating a README/LICENSE/.gitignore and creating the first branch of the project on the website.
Pictures related with the problem this MR fixes linked in #20025
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
Closes #20025
See merge request !5399
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 37 |
3 files changed, 42 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index 791b4435ae9..5c6fa8220c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ v 8.10.2 (unreleased) - Fix backup restore. !5459 - Rescue Rugged::OSError (lock exists) when creating references. !5497 - Disable MySQL foreign key checks before dropping all tables. !5472 + - Page is now properlty rendered after commiting the first file and creating the first branch - Fix a bug where forking a project from a repository storage to another would fail - Show release notes in tags list - Use project ID in repository cache to prevent stale data from persisting across projects. !5460 diff --git a/app/models/repository.rb b/app/models/repository.rb index d8775ecbd6c..9fd8f5ec787 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -988,6 +988,10 @@ class Repository if was_empty || !target_branch # Create branch rugged.references.create(ref, newrev) + + # If repo was empty expire cache + 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 881ab5ff8dc..5bc1bd9a930 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -446,6 +446,43 @@ describe Repository, models: true do end.to raise_error(GitHooksService::PreReceiveError) 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, '']) + end + + it 'expires creation and branch cache' do + empty_repository = create(:empty_project, :empty_repo).repository + + expect(empty_repository).to receive(:expire_exists_cache) + expect(empty_repository).to receive(:expire_root_ref_cache) + expect(empty_repository).to receive(:expire_emptiness_caches) + expect(empty_repository).to receive(:expire_branches_cache) + expect(empty_repository).to receive(:expire_has_visible_content_cache) + expect(empty_repository).to receive(:expire_branch_count_cache) + + empty_repository.commit_file(user, 'CHANGELOG', 'Changelog!', + 'Updates file content', 'master', false) + end + end end describe '#exists?' do |