diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-21 18:14:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-21 18:14:09 +0300 |
commit | e87220d9c1a7878a4cb2bb86554c5951371e340b (patch) | |
tree | fa8d81c8463cf97362f441f81dfef890df34ebbd /app/models/repository.rb | |
parent | c0a3d287c0d613cc439a31683d06dd70f3411f8c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index ee1bea0e8d2..81f1c385bf3 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -48,22 +48,19 @@ class Repository # For example, for entry `:commit_count` there's a method called `commit_count` which # stores its data in the `commit_count` cache key. CACHED_METHODS = %i(size commit_count readme_path contribution_guide - changelog license_blob license_key gitignore + changelog license_blob license_licensee license_gitaly gitignore gitlab_ci_yml branch_names tag_names branch_count tag_count avatar exists? root_ref merged_branch_names has_visible_content? issue_template_names_hash merge_request_template_names_hash user_defined_metrics_dashboard_paths xcode_project? has_ambiguous_refs?).freeze - # Methods that use cache_method but only memoize the value - MEMOIZED_CACHED_METHODS = %i(license).freeze - # Certain method caches should be refreshed when certain types of files are # changed. This Hash maps file types (as returned by Gitlab::FileDetector) to # the corresponding methods to call for refreshing caches. METHOD_CACHES_FOR_FILE_TYPES = { readme: %i(readme_path), changelog: :changelog, - license: %i(license_blob license_key license), + license: %i(license_blob license_licensee license_gitaly), contributing: :contribution_guide, gitignore: :gitignore, gitlab_ci: :gitlab_ci_yml, @@ -650,25 +647,30 @@ class Repository cache_method :license_blob def license_key - return unless exists? - - raw_repository.license_short_name + license&.key end - cache_method :license_key def license - return unless license_key + if Feature.enabled?(:license_from_gitaly) + license_gitaly + else + license_licensee + end + end - licensee_object = Licensee::License.new(license_key) + def license_licensee + return unless exists? - return if licensee_object.name.blank? + raw_repository.license(false) + end + cache_method :license_licensee - licensee_object - rescue Licensee::InvalidLicense => e - Gitlab::ErrorTracking.track_exception(e) - nil + def license_gitaly + return unless exists? + + raw_repository.license(true) end - memoize_method :license + cache_method :license_gitaly def gitignore file_on_head(:gitignore) |