Class: Repositories::TreeFinder
- Inherits:
-
Object
- Object
- Repositories::TreeFinder
- Defined in:
- app/finders/repositories/tree_finder.rb
Constant Summary collapse
- CommitMissingError =
Class.new(StandardError)
Instance Method Summary collapse
- #commit_exists? ⇒ Boolean
- #execute(gitaly_pagination: false) ⇒ Object
-
#initialize(project, params = {}) ⇒ TreeFinder
constructor
A new instance of TreeFinder.
- #total ⇒ Object
Constructor Details
#initialize(project, params = {}) ⇒ TreeFinder
Returns a new instance of TreeFinder.
7 8 9 10 11 |
# File 'app/finders/repositories/tree_finder.rb', line 7 def initialize(project, params = {}) @project = project @repository = project.repository @params = params end |
Instance Method Details
#commit_exists? ⇒ Boolean
30 31 32 |
# File 'app/finders/repositories/tree_finder.rb', line 30 def commit_exists? commit.present? end |
#execute(gitaly_pagination: false) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/finders/repositories/tree_finder.rb', line 13 def execute(gitaly_pagination: false) raise CommitMissingError unless commit_exists? request_params = { recursive: recursive, rescue_not_found: rescue_not_found } request_params[:pagination_params] = pagination_params if gitaly_pagination repository.tree(commit.id, path, **request_params).sorted_entries end |
#total ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/finders/repositories/tree_finder.rb', line 22 def total # This is inefficient and we'll look at replacing this implementation cache_key = [project, repository.commit, :tree_size, commit.id, path, recursive] Gitlab::Cache.fetch_once(cache_key) do repository.tree(commit.id, path, recursive: recursive).entries.size end end |