Class: Gitlab::Git::Push
- Inherits:
-
Object
- Object
- Gitlab::Git::Push
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/git/push.rb
Instance Attribute Summary collapse
-
#newrev ⇒ Object
readonly
Returns the value of attribute newrev.
-
#oldrev ⇒ Object
readonly
Returns the value of attribute oldrev.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #branch_added? ⇒ Boolean
- #branch_name ⇒ Object
- #branch_push? ⇒ Boolean
- #branch_removed? ⇒ Boolean
- #branch_updated? ⇒ Boolean
- #force_push? ⇒ Boolean
-
#initialize(project, oldrev, newrev, ref) ⇒ Push
constructor
A new instance of Push.
- #modified_paths ⇒ Object
Constructor Details
#initialize(project, oldrev, newrev, ref) ⇒ Push
Returns a new instance of Push.
10 11 12 13 14 15 |
# File 'lib/gitlab/git/push.rb', line 10 def initialize(project, oldrev, newrev, ref) @project = project @oldrev = oldrev.presence || Gitlab::Git::BLANK_SHA @newrev = newrev.presence || Gitlab::Git::BLANK_SHA @ref = ref end |
Instance Attribute Details
#newrev ⇒ Object (readonly)
Returns the value of attribute newrev.
8 9 10 |
# File 'lib/gitlab/git/push.rb', line 8 def newrev @newrev end |
#oldrev ⇒ Object (readonly)
Returns the value of attribute oldrev.
8 9 10 |
# File 'lib/gitlab/git/push.rb', line 8 def oldrev @oldrev end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
8 9 10 |
# File 'lib/gitlab/git/push.rb', line 8 def ref @ref end |
Instance Method Details
#branch_added? ⇒ Boolean
23 24 25 |
# File 'lib/gitlab/git/push.rb', line 23 def branch_added? Gitlab::Git.blank_ref?(@oldrev) end |
#branch_name ⇒ Object
17 18 19 20 21 |
# File 'lib/gitlab/git/push.rb', line 17 def branch_name strong_memoize(:branch_name) do Gitlab::Git.branch_name(@ref) end end |
#branch_push? ⇒ Boolean
41 42 43 44 45 |
# File 'lib/gitlab/git/push.rb', line 41 def branch_push? strong_memoize(:branch_push) do Gitlab::Git.branch_ref?(@ref) end end |
#branch_removed? ⇒ Boolean
27 28 29 |
# File 'lib/gitlab/git/push.rb', line 27 def branch_removed? Gitlab::Git.blank_ref?(@newrev) end |
#branch_updated? ⇒ Boolean
31 32 33 |
# File 'lib/gitlab/git/push.rb', line 31 def branch_updated? branch_push? && !branch_added? && !branch_removed? end |
#force_push? ⇒ Boolean
35 36 37 38 39 |
# File 'lib/gitlab/git/push.rb', line 35 def force_push? strong_memoize(:force_push) do Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev) end end |
#modified_paths ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/gitlab/git/push.rb', line 47 def modified_paths unless branch_updated? raise ArgumentError, 'Unable to calculate modified paths!' end strong_memoize(:modified_paths) do @project.repository.diff_stats(@oldrev, @newrev).paths end end |