Skip to content
Snippets Groups Projects
Commit 7e4bde8f authored by James Lopez's avatar James Lopez
Browse files

Commit.find returns nil and no longer throws an error on an empty repository

Also added relevant spec with broken repo.
parent 5870f87d
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