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: 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.
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, #force_encode_utf8, #strip_bom, #unquote_path
Constructor Details
#initialize(options) ⇒ Tree
Returns a new instance of Tree.
72 73 74 75 76 |
# File 'lib/gitlab/git/tree.rb', line 72 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
86 87 88 |
# File 'lib/gitlab/git/tree.rb', line 86 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
78 79 80 |
# File 'lib/gitlab/git/tree.rb', line 78 def name encode! @name end |
#path ⇒ Object
82 83 84 |
# File 'lib/gitlab/git/tree.rb', line 82 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: 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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/git/tree.rb', line 15 def tree_entries( repository:, sha:, path: nil, recursive: false, skip_flat_paths: true, rescue_not_found: true, pagination_params: nil ) path = nil if path == '' || path == '/' 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 |
Instance Method Details
#contributing? ⇒ Boolean
106 107 108 |
# File 'lib/gitlab/git/tree.rb', line 106 def contributing? name =~ /^contributing/i end |
#dir? ⇒ Boolean
90 91 92 |
# File 'lib/gitlab/git/tree.rb', line 90 def dir? type == :tree end |
#file? ⇒ Boolean
94 95 96 |
# File 'lib/gitlab/git/tree.rb', line 94 def file? type == :blob end |
#readme? ⇒ Boolean
102 103 104 |
# File 'lib/gitlab/git/tree.rb', line 102 def readme? name =~ /^readme/i end |
#submodule? ⇒ Boolean
98 99 100 |
# File 'lib/gitlab/git/tree.rb', line 98 def submodule? type == :commit end |