Class: CaptainHook::Events::PostReceive
- Inherits:
-
Object
- Object
- CaptainHook::Events::PostReceive
- Defined in:
- lib/captain_hook/events/post_receive.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 = {}) ⇒ PostReceive
constructor
A new instance of PostReceive.
-
#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 = {}) ⇒ PostReceive
Returns a new instance of PostReceive.
6 7 8 9 10 11 |
# File 'lib/captain_hook/events/post_receive.rb', line 6 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.
4 5 6 |
# File 'lib/captain_hook/events/post_receive.rb', line 4 def new_commit @new_commit end |
#old_commit ⇒ Object
Returns the value of attribute old_commit.
4 5 6 |
# File 'lib/captain_hook/events/post_receive.rb', line 4 def old_commit @old_commit end |
#repo ⇒ Object
Returns the value of attribute repo.
4 5 6 |
# File 'lib/captain_hook/events/post_receive.rb', line 4 def repo @repo end |
Instance Method Details
#author ⇒ Object
Returns the author of the most-recent revision
25 26 27 |
# File 'lib/captain_hook/events/post_receive.rb', line 25 def new_commit. end |
#commits ⇒ Object
13 14 15 |
# File 'lib/captain_hook/events/post_receive.rb', line 13 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
30 31 32 |
# File 'lib/captain_hook/events/post_receive.rb', line 30 def @message ||= new_commit..split("\n")[0] end |
#message_detail ⇒ Object
Returns lines 1..n of the most recent revision’s commit message
35 36 37 38 39 40 41 42 |
# File 'lib/captain_hook/events/post_receive.rb', line 35 def @message_detail ||= begin new_commit.. split("\n")[1..-1]. reject{|s| s == ""}. join("\n") end end |
#ref_name ⇒ Object
17 18 19 20 21 22 |
# File 'lib/captain_hook/events/post_receive.rb', line 17 def ref_name @ref_name ||= begin @full_ref_name =~ %r{^refs/(?:tags|heads|remotes)/(.+)} ? $1 : "unknown" end end |