Class: Gitlab::Git::ChangedPath
- Inherits:
-
Object
- Object
- Gitlab::Git::ChangedPath
- Defined in:
- lib/gitlab/git/changed_path.rb
Instance Attribute Summary collapse
-
#commit_id ⇒ Object
readonly
Returns the value of attribute commit_id.
-
#new_blob_id ⇒ Object
readonly
Returns the value of attribute new_blob_id.
-
#new_mode ⇒ Object
readonly
Returns the value of attribute new_mode.
-
#old_blob_id ⇒ Object
readonly
Returns the value of attribute old_blob_id.
-
#old_mode ⇒ Object
readonly
Returns the value of attribute old_mode.
-
#old_path ⇒ Object
readonly
Returns the value of attribute old_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #deleted_file? ⇒ Boolean
-
#initialize(status:, path:, old_mode:, new_mode:, new_blob_id: nil, old_blob_id: nil, old_path: nil, commit_id: nil) ⇒ ChangedPath
constructor
A new instance of ChangedPath.
- #modified_file? ⇒ Boolean
- #new_file? ⇒ Boolean
- #renamed_file? ⇒ Boolean
- #submodule_change? ⇒ Boolean
Constructor Details
#initialize(status:, path:, old_mode:, new_mode:, new_blob_id: nil, old_blob_id: nil, old_path: nil, commit_id: nil) ⇒ ChangedPath
Returns a new instance of ChangedPath.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gitlab/git/changed_path.rb', line 8 def initialize( status:, path:, old_mode:, new_mode:, new_blob_id: nil, old_blob_id: nil, old_path: nil, commit_id: nil) @status = status @path = path @old_mode = old_mode @new_mode = new_mode @old_blob_id = old_blob_id @new_blob_id = new_blob_id @old_path = old_path.presence || @path @commit_id = commit_id end |
Instance Attribute Details
#commit_id ⇒ Object (readonly)
Returns the value of attribute commit_id.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def commit_id @commit_id end |
#new_blob_id ⇒ Object (readonly)
Returns the value of attribute new_blob_id.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def new_blob_id @new_blob_id end |
#new_mode ⇒ Object (readonly)
Returns the value of attribute new_mode.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def new_mode @new_mode end |
#old_blob_id ⇒ Object (readonly)
Returns the value of attribute old_blob_id.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def old_blob_id @old_blob_id end |
#old_mode ⇒ Object (readonly)
Returns the value of attribute old_mode.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def old_mode @old_mode end |
#old_path ⇒ Object (readonly)
Returns the value of attribute old_path.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def old_path @old_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def path @path end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/gitlab/git/changed_path.rb', line 6 def status @status end |
Instance Method Details
#deleted_file? ⇒ Boolean
25 26 27 |
# File 'lib/gitlab/git/changed_path.rb', line 25 def deleted_file? status == :DELETED end |
#modified_file? ⇒ Boolean
33 34 35 |
# File 'lib/gitlab/git/changed_path.rb', line 33 def modified_file? status == :MODIFIED end |
#new_file? ⇒ Boolean
21 22 23 |
# File 'lib/gitlab/git/changed_path.rb', line 21 def new_file? status == :ADDED end |
#renamed_file? ⇒ Boolean
29 30 31 |
# File 'lib/gitlab/git/changed_path.rb', line 29 def renamed_file? status == :RENAMED end |
#submodule_change? ⇒ Boolean
37 38 39 40 41 42 43 44 45 |
# File 'lib/gitlab/git/changed_path.rb', line 37 def submodule_change? # The file mode 160000 represents a "Gitlink" or a git submodule. # The first two digits can be used to distinguish it from regular files. # # 160000 -> 16 -> gitlink # 100644 -> 10 -> regular file [old_mode, new_mode].any? { |mode| mode.starts_with?('16') } end |