summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-03-01 17:10:39 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-03-01 17:10:39 +0000
commit52e133d17627396f29c1875b972534eaba4a837e (patch)
tree36b0c306afe21a270ce0f0fe9b396607778bc271 /lib
parentb19a14473099073dff3e770c00f73ddab4a0a414 (diff)
parent34fbade4ae67b56061da89fc881781352880b4ed (diff)
downloadgitlab-ce-52e133d17627396f29c1875b972534eaba4a837e.tar.gz
Merge branch 'zj-licensee-key' into 'master'43548-update-language-about-usage-ping-in-admin-settings-and-docs
Client implementation for Licensee#key See merge request gitlab-org/gitlab-ce!17449
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/repository.rb15
-rw-r--r--lib/gitlab/gitaly_client/repository_service.rb8
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 1c964960983..d7c373ccd6f 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1038,6 +1038,21 @@ module Gitlab
end
end
+ def license_short_name
+ gitaly_migrate(:license_short_name) do |is_enabled|
+ 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
+
def with_repo_branch_commit(start_repository, start_branch_name)
Gitlab::Git.check_namespace!(start_repository)
start_repository = RemoteRepository.new(start_repository) unless start_repository.is_a?(RemoteRepository)
diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb
index d7e40471798..fdb3247cf4d 100644
--- a/lib/gitlab/gitaly_client/repository_service.rb
+++ b/lib/gitlab/gitaly_client/repository_service.rb
@@ -249,6 +249,14 @@ module Gitlab
raise Gitlab::Git::OSError.new(response.error) unless response.error.empty?
end
+
+ def license_short_name
+ request = Gitaly::FindLicenseRequest.new(repository: @gitaly_repo)
+
+ response = GitalyClient.call(@storage, :repository_service, :find_license, request, timeout: GitalyClient.fast_timeout)
+
+ response.license_short_name.presence
+ end
end
end
end