Commit 45f9c9f7 authored by Rémy Coutable's avatar Rémy Coutable

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"

See merge request !5399
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent c978bed8
......@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.2 (unreleased)
- User can now search branches by name. !5144
- Page is now properlty rendered after commiting the first file and creating the first branch. !5399
- Add branch or tag icon to ref in builds page. !5434
- Fix backup restore. !5459
- Use project ID in repository cache to prevent stale data from persisting across projects. !5460
......
......@@ -1000,6 +1000,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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment