Commit f16eabfc authored by Hannes Rosenögger's avatar Hannes Rosenögger

Display project icon from default branch

This commit makes sure that the project icon is
being read from the default branch instead of
'master'
parent 7bbb523b
...@@ -17,6 +17,7 @@ v 8.11.1 (unreleased) ...@@ -17,6 +17,7 @@ v 8.11.1 (unreleased)
- Does not halt the GitHub import process when an error occurs - Does not halt the GitHub import process when an error occurs
- Fix file links on project page when default view is Files !5933 - Fix file links on project page when default view is Files !5933
- Change using size to use count and caching it for number of group members - Change using size to use count and caching it for number of group members
- Use the default branch for displaying the project icon instead of master !5792 (Hannes Rosenögger)
v 8.11.0 v 8.11.0
- Use test coverage value from the latest successful pipeline in badge. !5862 - Use test coverage value from the latest successful pipeline in badge. !5862
......
...@@ -4,7 +4,7 @@ class Projects::AvatarsController < Projects::ApplicationController ...@@ -4,7 +4,7 @@ class Projects::AvatarsController < Projects::ApplicationController
before_action :authorize_admin_project!, only: [:destroy] before_action :authorize_admin_project!, only: [:destroy]
def show def show
@blob = @repository.blob_at_branch('master', @project.avatar_in_git) @blob = @repository.blob_at_branch(@repository.root_ref, @project.avatar_in_git)
if @blob if @blob
headers['X-Content-Type-Options'] = 'nosniff' headers['X-Content-Type-Options'] = 'nosniff'
......
...@@ -1035,6 +1035,7 @@ class Project < ActiveRecord::Base ...@@ -1035,6 +1035,7 @@ class Project < ActiveRecord::Base
"refs/heads/#{branch}", "refs/heads/#{branch}",
force: true) force: true)
repository.copy_gitattributes(branch) repository.copy_gitattributes(branch)
repository.expire_avatar_cache(branch)
reload_default_branch reload_default_branch
end end
......
...@@ -1065,7 +1065,7 @@ class Repository ...@@ -1065,7 +1065,7 @@ class Repository
@avatar ||= cache.fetch(:avatar) do @avatar ||= cache.fetch(:avatar) do
AVATAR_FILES.find do |file| AVATAR_FILES.find do |file|
blob_at_branch('master', file) blob_at_branch(root_ref, file)
end end
end end
end end
......
...@@ -1442,4 +1442,35 @@ describe Project, models: true do ...@@ -1442,4 +1442,35 @@ describe Project, models: true do
expect(shared_project.authorized_for_user?(master, Gitlab::Access::MASTER)).to be(true) expect(shared_project.authorized_for_user?(master, Gitlab::Access::MASTER)).to be(true)
end end
end end
describe 'change_head' do
let(:project) { create(:project) }
it 'calls the before_change_head method' do
expect(project.repository).to receive(:before_change_head)
project.change_head(project.default_branch)
end
it 'creates the new reference with rugged' do
expect(project.repository.rugged.references).to receive(:create).with('HEAD',
"refs/heads/#{project.default_branch}",
force: true)
project.change_head(project.default_branch)
end
it 'copies the gitattributes' do
expect(project.repository).to receive(:copy_gitattributes).with(project.default_branch)
project.change_head(project.default_branch)
end
it 'expires the avatar cache' do
expect(project.repository).to receive(:expire_avatar_cache).with(project.default_branch)
project.change_head(project.default_branch)
end
it 'reloads the default branch' do
expect(project).to receive(:reload_default_branch)
project.change_head(project.default_branch)
end
end
end end
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