Skip to content
Snippets Groups Projects
Commit fc105f0d authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'fix/commit-no-repo-error' into 'master'

Fix broken repo error raised after requesting a commit

Prevents a 500 error on screen after `Rugged::RepositoryError: Could not find repository from '/var/opt/gitlab/git-data/repositories/user/project.git'`, which could happen when checking for the last commit in the list of projects (dashboard).

Related https://gitlab.com/gitlab-org/gitlab-ce/issues/20501

See merge request !124
parents 5870f87d 7e4bde8f
No related branches found
No related tags found
1 merge request!124Fix broken repo error raised after requesting a commit
Pipeline #
v 10.6.7
- Commit.find returns nil and no longer throws an error on an empty repository
v 10.6.6
- The Git attributes parser can now parse file paths without any attributes
 
Loading
Loading
10.6.6
10.6.7
Loading
Loading
@@ -64,7 +64,7 @@ module Gitlab
return nil unless obj.is_a?(Rugged::Commit)
 
decorate(obj)
rescue Rugged::ReferenceError, Rugged::InvalidError, Rugged::ObjectError
rescue Rugged::ReferenceError, Rugged::InvalidError, Rugged::ObjectError, Gitlab::Git::Repository::NoRepository
nil
end
 
Loading
Loading
Loading
Loading
@@ -93,6 +93,14 @@ describe Gitlab::Git::Commit do
it "should return nil for nonexisting ids" do
expect(Gitlab::Git::Commit.find(repository, "+123_4532530XYZ")).to be_nil
end
context 'with broken repo' do
let(:repository) { Gitlab::Git::Repository.new(TEST_BROKEN_REPO_PATH) }
it 'returns nil' do
expect(Gitlab::Git::Commit.find(repository, SeedRepo::Commit::ID)).to be_nil
end
end
end
 
describe :last_for_path do
Loading
Loading
Loading
Loading
@@ -33,6 +33,7 @@ SUPPORT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), '../support')
TEST_REPO_PATH = File.join(SUPPORT_PATH, 'gitlab-git-test.git')
TEST_NORMAL_REPO_PATH = File.join(SUPPORT_PATH, "not-bare-repo.git")
TEST_MUTABLE_REPO_PATH = File.join(SUPPORT_PATH, "mutable-repo.git")
TEST_BROKEN_REPO_PATH = File.join(SUPPORT_PATH, "broken-repo.git")
 
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
Loading
Loading
Loading
Loading
@@ -11,6 +11,7 @@ module SeedHelper
create_bare_seeds
create_normal_seeds
create_mutable_seeds
create_broken_seeds
create_git_attributes
end
 
Loading
Loading
@@ -39,6 +40,16 @@ module SeedHelper
chdir: TEST_MUTABLE_REPO_PATH, out: '/dev/null', err: '/dev/null')
end
 
def create_broken_seeds
system(git_env, *%W(git clone --bare #{TEST_REPO_PATH} #{TEST_BROKEN_REPO_PATH}),
out: '/dev/null',
err: '/dev/null')
refs_path = File.join(TEST_BROKEN_REPO_PATH, 'refs')
FileUtils.rm_r(refs_path)
end
def create_git_attributes
dir = File.join(SUPPORT_PATH, 'with-git-attributes.git', 'info')
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment