Class: CaptainHook::PostReceiveEvent
- Inherits:
-
Object
- Object
- CaptainHook::PostReceiveEvent
- Defined in:
- lib/captain_hook/post_receive_event.rb
Instance Attribute Summary collapse
-
#new_commit ⇒ Object
Returns the value of attribute new_commit.
-
#old_commit ⇒ Object
Returns the value of attribute old_commit.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
-
#author ⇒ Object
Returns the author of the most-recent revision.
- #commits ⇒ Object
-
#initialize(options = {}) ⇒ PostReceiveEvent
constructor
A new instance of PostReceiveEvent.
-
#message ⇒ Object
Returns the first line of the most recent revision’s commit message.
-
#message_detail ⇒ Object
Returns lines 1..n of the most recent revision’s commit message.
- #ref_name ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PostReceiveEvent
Returns a new instance of PostReceiveEvent.
5 6 7 8 9 10 |
# File 'lib/captain_hook/post_receive_event.rb', line 5 def initialize( = {}) @repo = [:repo] @old_commit = @repo.commit([:old_sha]) @new_commit = @repo.commit([:new_sha]) @full_ref_name = [:ref_name] end |
Instance Attribute Details
#new_commit ⇒ Object
Returns the value of attribute new_commit.
3 4 5 |
# File 'lib/captain_hook/post_receive_event.rb', line 3 def new_commit @new_commit end |
#old_commit ⇒ Object
Returns the value of attribute old_commit.
3 4 5 |
# File 'lib/captain_hook/post_receive_event.rb', line 3 def old_commit @old_commit end |
#repo ⇒ Object
Returns the value of attribute repo.
3 4 5 |
# File 'lib/captain_hook/post_receive_event.rb', line 3 def repo @repo end |
Instance Method Details
#author ⇒ Object
Returns the author of the most-recent revision
24 25 26 |
# File 'lib/captain_hook/post_receive_event.rb', line 24 def new_commit. end |
#commits ⇒ Object
12 13 14 |
# File 'lib/captain_hook/post_receive_event.rb', line 12 def commits @commits ||= @repo.commits_between(new_commit, old_commit) end |
#message ⇒ Object
Returns the first line of the most recent revision’s commit message
29 30 31 |
# File 'lib/captain_hook/post_receive_event.rb', line 29 def @message ||= new_commit..split("\n")[0] end |
#message_detail ⇒ Object
Returns lines 1..n of the most recent revision’s commit message
34 35 36 37 38 39 40 41 |
# File 'lib/captain_hook/post_receive_event.rb', line 34 def @message_detail ||= begin new_commit.. split("\n")[1..-1]. reject{|s| s == ""}. join("\n") end end |
#ref_name ⇒ Object
16 17 18 19 20 21 |
# File 'lib/captain_hook/post_receive_event.rb', line 16 def ref_name @ref_name ||= begin @full_ref_name =~ %r{^refs/(?:tags|heads|remotes)/(.+)} ? $1 : "unknown" end end |