Commit 7a42d865 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-gitaly-license-detection' into 'master'

License detection happens solely through Gitaly now

Closes gitaly#1026

See merge request gitlab-org/gitlab-ce!19986
parents 05474b35 da8419a1
...@@ -1054,18 +1054,8 @@ module Gitlab ...@@ -1054,18 +1054,8 @@ module Gitlab
end end
def license_short_name def license_short_name
gitaly_migrate(:license_short_name, wrapped_gitaly_errors do
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled| gitaly_repository_client.license_short_name
if is_enabled
gitaly_repository_client.license_short_name
else
begin
# 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
Licensee.license(path).try(:key)
rescue Rugged::Error
end
end
end end
end end
......
...@@ -1727,31 +1727,21 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1727,31 +1727,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
describe '#license_short_name' do describe '#license_short_name' do
shared_examples 'acquiring the Licensee license key' do subject { repository.license_short_name }
subject { repository.license_short_name }
context 'when no license file can be found' do context 'when no license file can be found' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw_repository } let(:repository) { project.repository.raw_repository }
before do
project.repository.delete_file(project.owner, 'LICENSE', message: 'remove license', branch_name: 'master')
end
it { is_expected.to be_nil }
end
context 'when an mit license is found' do before do
it { is_expected.to eq('mit') } project.repository.delete_file(project.owner, 'LICENSE', message: 'remove license', branch_name: 'master')
end end
end
context 'when gitaly is enabled' do it { is_expected.to be_nil }
it_behaves_like 'acquiring the Licensee license key'
end end
context 'when gitaly is disabled', :disable_gitaly do context 'when an mit license is found' do
it_behaves_like 'acquiring the Licensee license key' it { is_expected.to eq('mit') }
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