Class: Gitlab::Git::Tree
- Inherits:
-
Object
- Object
- Gitlab::Git::Tree
- Extended by:
- WrapsGitalyErrors
- Includes:
- EncodingHelper
- Defined in:
- lib/gitlab/git/tree.rb
Constant Summary
Constants included from EncodingHelper
EncodingHelper::BOM_UTF8, EncodingHelper::ENCODING_CONFIDENCE_THRESHOLD, EncodingHelper::ESCAPED_CHARS, EncodingHelper::UNICODE_REPLACEMENT_CHARACTER
Instance Attribute Summary collapse
-
#commit_id ⇒ Object
Returns the value of attribute commit_id.
- #flat_path ⇒ Object
-
#id ⇒ Object
Returns the value of attribute id.
-
#mode ⇒ Object
Returns the value of attribute mode.
- #name ⇒ Object
- #path ⇒ Object
-
#ref_type ⇒ Object
Returns the value of attribute ref_type.
-
#submodule_url ⇒ Object
Returns the value of attribute submodule_url.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .tree_entries(repository, sha, path, recursive, skip_flat_paths, rescue_not_found, pagination_params = nil) ⇒ Object
-
.where(repository, sha, path = nil, recursive = false, skip_flat_paths = true, rescue_not_found = true, pagination_params = nil) ⇒ Object
Get list of tree objects for repository based on commit sha and path Uses rugged for raw objects.
Instance Method Summary collapse
- #contributing? ⇒ Boolean
- #dir? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(options) ⇒ Tree
constructor
A new instance of Tree.
- #readme? ⇒ Boolean
- #submodule? ⇒ Boolean
Methods included from WrapsGitalyErrors
Methods included from EncodingHelper
#binary_io, #detect_binary?, #detect_encoding, #detect_libgit2_binary?, #encode!, #encode_binary, #encode_utf8, #encode_utf8_no_detect, #encode_utf8_with_escaping!, #encode_utf8_with_replacement_character, #strip_bom, #unquote_path
Constructor Details
#initialize(options) ⇒ Tree
Returns a new instance of Tree.
73 74 75 76 77 |
# File 'lib/gitlab/git/tree.rb', line 73 def initialize() %w[id name path flat_path type mode commit_id].each do |key| self.send("#{key}=", [key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend end end |
Instance Attribute Details
#commit_id ⇒ Object
Returns the value of attribute commit_id.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def commit_id @commit_id end |
#flat_path ⇒ Object
87 88 89 |
# File 'lib/gitlab/git/tree.rb', line 87 def flat_path encode! @flat_path end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def id @id end |
#mode ⇒ Object
Returns the value of attribute mode.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def mode @mode end |
#name ⇒ Object
79 80 81 |
# File 'lib/gitlab/git/tree.rb', line 79 def name encode! @name end |
#path ⇒ Object
83 84 85 |
# File 'lib/gitlab/git/tree.rb', line 83 def path encode! @path end |
#ref_type ⇒ Object
Returns the value of attribute ref_type.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def ref_type @ref_type end |
#submodule_url ⇒ Object
Returns the value of attribute submodule_url.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def submodule_url @submodule_url end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/gitlab/git/tree.rb', line 9 def type @type end |
Class Method Details
.tree_entries(repository, sha, path, recursive, skip_flat_paths, rescue_not_found, pagination_params = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitlab/git/tree.rb', line 26 def tree_entries(repository, sha, path, recursive, skip_flat_paths, rescue_not_found, pagination_params = nil) wrapped_gitaly_errors do repository.gitaly_commit_client.tree_entries( repository, sha, path, recursive, skip_flat_paths, pagination_params) end # Incorrect revision or path could lead to index error. # We silently handle such errors by returning an empty set of entries and cursor # unless the parameter rescue_not_found is set to false. rescue Gitlab::Git::Index::IndexError => e return [[], nil] if rescue_not_found raise e end |
.where(repository, sha, path = nil, recursive = false, skip_flat_paths = true, rescue_not_found = true, pagination_params = nil) ⇒ Object
Get list of tree objects for repository based on commit sha and path Uses rugged for raw objects
Gitaly migration: gitlab.com/gitlab-org/gitaly/issues/320
18 19 20 21 22 23 24 |
# File 'lib/gitlab/git/tree.rb', line 18 def where( repository, sha, path = nil, recursive = false, skip_flat_paths = true, rescue_not_found = true, pagination_params = nil) path = nil if path == '' || path == '/' tree_entries(repository, sha, path, recursive, skip_flat_paths, rescue_not_found, pagination_params) end |
Instance Method Details
#contributing? ⇒ Boolean
107 108 109 |
# File 'lib/gitlab/git/tree.rb', line 107 def contributing? name =~ /^contributing/i end |
#dir? ⇒ Boolean
91 92 93 |
# File 'lib/gitlab/git/tree.rb', line 91 def dir? type == :tree end |
#file? ⇒ Boolean
95 96 97 |
# File 'lib/gitlab/git/tree.rb', line 95 def file? type == :blob end |
#readme? ⇒ Boolean
103 104 105 |
# File 'lib/gitlab/git/tree.rb', line 103 def readme? name =~ /^readme/i end |
#submodule? ⇒ Boolean
99 100 101 |
# File 'lib/gitlab/git/tree.rb', line 99 def submodule? type == :commit end |