Commit 5b3b2b82 authored by Stan Hu's avatar Stan Hu

Simplify license generator error handling

parent bc11af67
......@@ -597,7 +597,7 @@ class Repository
# The licensee gem creates a Rugged object from the path:
# https://github.com/benbalter/licensee/blob/v8.7.0/lib/licensee/projects/git_project.rb
begin
Licensee.project(path, revision: head_commit.sha).license.try(:key)
Licensee.license(path).try(:key)
# Normally we would rescue Rugged::Error, but that is banned by lint-rugged
# and we need to migrate this endpoint to Gitaly:
# https://gitlab.com/gitlab-org/gitaly/issues/1026
......
......@@ -879,11 +879,10 @@ describe Repository do
expect(repository.license_key).to be_nil
end
it 'returns the license key even when master does not exist' do
it 'returns nil when master does not exist' do
repository.rm_branch(user, 'master')
project.change_head('test')
expect(repository.license_key).to eq('mit')
expect(repository.license_key).to be_nil
end
it 'returns the license key' 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