Commit 1dac44bf authored by Stan Hu's avatar Stan Hu Committed by Valery Sizov

Fix Error 500 when browsing projects with no HEAD

Steps to reproduce:
1. Create a project with a README
2. In the actual remote, type: `git symbolic-ref HEAD refs/heads/nowhere`
3. Check that HEAD is gone via `git ls-remote .`
4. Go to the projects page and see the Error 500

Closes https://github.com/gitlabhq/gitlabhq/issues/9484
parent 7cf651eb
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
- Fix Error 500 when browsing projects with no HEAD (Stan Hu)
- Fix full screen mode for snippet comments (Daniel Gerhardt)
- Fix 404 error in files view after deleting the last file in a repository (Stan Hu)
- Fix label read access for unauthenticated users (Daniel Gerhardt)
- Fix access to disabled features for unauthenticated users (Daniel Gerhardt)
- Fix OAuth provider bug where GitLab would not go return to the redirect_uri after sign-in (Stan Hu)
- Fix file upload dialog for comment editing (Daniel Gerhardt)
- Set OmniAuth full_host parameter to ensure redirect URIs are correct (Stan Hu)
- Expire Rails cache entries after two weeks to prevent endless Redis growth
- Add support for destroying project milestones (Stan Hu)
- Add fetch command to the MR page.
- Fix bug causing "Remove source-branch" option not to work for merge requests from the same project.
v 7.13.1 v 7.13.1
- Fix: Label modifications are not reflected in existing notes and in the issue list - Fix: Label modifications are not reflected in existing notes and in the issue list
- Fix: Label not shown in the Issue list, although it's set through web interface - Fix: Label not shown in the Issue list, although it's set through web interface
......
...@@ -274,7 +274,8 @@ module ProjectsHelper ...@@ -274,7 +274,8 @@ module ProjectsHelper
end end
def readme_cache_key def readme_cache_key
[@project.id, @project.commit.sha, "readme"].join('-') sha = @project.commit.try(:sha) || 'nil'
[@project.id, sha, "readme"].join('-')
end end
def round_commit_count(project) def round_commit_count(project)
......
...@@ -22,7 +22,7 @@ describe ProjectsHelper do ...@@ -22,7 +22,7 @@ describe ProjectsHelper do
let(:user) { create(:user) } let(:user) { create(:user) }
it "returns false if there are no approipriate permissions" do it "returns false if there are no appropriate permissions" do
allow(helper).to receive(:can?) { false } allow(helper).to receive(:can?) { false }
expect(helper.can_change_visibility_level?(project, user)).to be_falsey expect(helper.can_change_visibility_level?(project, user)).to be_falsey
...@@ -52,4 +52,22 @@ describe ProjectsHelper do ...@@ -52,4 +52,22 @@ describe ProjectsHelper do
end end
end end
end end
describe "readme_cache_key" do
let(:project) { create(:project) }
before do
helper.instance_variable_set(:@project, project)
end
it "returns a valid cach key" do
expect(helper.send(:readme_cache_key)).to eq("#{project.id}-#{project.commit.id}-readme")
end
it "returns a valid cache key if HEAD does not exist" do
allow(project).to receive(:commit) { nil }
expect(helper.send(:readme_cache_key)).to eq("#{project.id}-nil-readme")
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