Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb45
1 files changed, 16 insertions, 29 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index c19448332f8..ba13b67d101 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -39,7 +39,7 @@ 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 rendered_readme readme_path contribution_guide
+ CACHED_METHODS = %i(size commit_count readme_path contribution_guide
changelog license_blob license_key gitignore
gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref merged_branch_names
@@ -53,7 +53,7 @@ class Repository
# 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(rendered_readme readme_path),
+ readme: %i(readme_path),
changelog: :changelog,
license: %i(license_blob license_key license),
contributing: :contribution_guide,
@@ -151,7 +151,8 @@ class Repository
all: !!opts[:all],
first_parent: !!opts[:first_parent],
order: opts[:order],
- literal_pathspec: opts.fetch(:literal_pathspec, true)
+ literal_pathspec: opts.fetch(:literal_pathspec, true),
+ trailers: opts[:trailers]
}
commits = Gitlab::Git::Commit.where(options)
@@ -497,23 +498,7 @@ class Repository
end
def blob_at(sha, path)
- blob = Blob.decorate(raw_repository.blob_at(sha, path), container)
-
- # Don't attempt to return a special result if there is no blob at all
- return unless blob
-
- # Don't attempt to return a special result if this can't be a README
- return blob unless Gitlab::FileDetector.type_of(blob.name) == :readme
-
- # Don't attempt to return a special result unless we're looking at HEAD
- return blob unless head_commit&.sha == sha
-
- case path
- when head_tree&.readme_path
- ReadmeBlob.new(blob, self)
- else
- blob
- end
+ Blob.decorate(raw_repository.blob_at(sha, path), container)
rescue Gitlab::Git::Repository::NoRepository
nil
end
@@ -611,15 +596,6 @@ class Repository
end
cache_method :readme_path
- def rendered_readme
- return unless readme
-
- context = { project: project }
-
- MarkupHelper.markup_unsafe(readme.name, readme.data, context)
- end
- cache_method :rendered_readme
-
def contribution_guide
file_on_head(:contributing)
end
@@ -1058,6 +1034,10 @@ class Repository
blob_data_at(sha, '.lfsconfig')
end
+ def changelog_config(ref = 'HEAD')
+ blob_data_at(ref, Gitlab::Changelog::Config::FILE_PATH)
+ end
+
def fetch_ref(source_repository, source_ref:, target_ref:)
raw_repository.fetch_ref(source_repository.raw_repository, source_ref: source_ref, target_ref: target_ref)
end
@@ -1142,6 +1122,13 @@ class Repository
end
end
+ # Choose one of the available repository storage options based on a normalized weighted probability.
+ # We should always use the latest settings, to avoid picking a deleted shard.
+ def self.pick_storage_shard(expire: true)
+ Gitlab::CurrentSettings.expire_current_application_settings if expire
+ Gitlab::CurrentSettings.pick_repository_storage
+ end
+
private
# TODO Genericize finder, later split this on finders by Ref or Oid