Class: RGitHook::Commit
- Inherits:
-
Object
- Object
- RGitHook::Commit
- Defined in:
- lib/rgithook/githook.rb
Overview
Commit Identifica a un único commit
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(commit) ⇒ Commit
constructor
A new instance of Commit.
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(commit) ⇒ Commit
Returns a new instance of Commit.
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/rgithook/githook.rb', line 136 def initialize(commit) @commit = commit log = Git.cat_file(commit).split("\n") = log[5..-1].join("\n") = log[2].split(" ")[1..-3].join(" ") @date = Time.at log[2].split(" ")[-2].to_i @files = Git.diff_numstat( commit ).split("\n").map {|f| f.split("\t")}.map do |f| diff = Git.diff_path( commit, f[2] ) CommitFile.new(f[2],f[0],f[1], diff ) end end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
135 136 137 |
# File 'lib/rgithook/githook.rb', line 135 def end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
135 136 137 |
# File 'lib/rgithook/githook.rb', line 135 def commit @commit end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
135 136 137 |
# File 'lib/rgithook/githook.rb', line 135 def date @date end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
135 136 137 |
# File 'lib/rgithook/githook.rb', line 135 def files @files end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
135 136 137 |
# File 'lib/rgithook/githook.rb', line 135 def end |
Instance Method Details
#to_html ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rgithook/githook.rb', line 153 def to_html html = "" html << "<div>" html << "<dl style='font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; border: 1px #006 solid; background: #369; padding: 6px; color: #fff;'>\n" html << "<dt style='float: left; width: 6em; font-weight: bold;'>sha1:</dt><dd>#{@commit}</dd>\n" html << "<dt style='float: left; width: 6em; font-weight: bold;'>author:</dt><dd>#{Helpers.html_escape(@author)}</dd>\n" html << "<dt style='float: left; width: 6em; font-weight: bold;'>date:</dt><dd>#{@date}</dd>\n" html << "<dt style='float: left; width: 6em; font-weight: bold;'>message:</dt><dd>\n\t#{Helpers.html_escape(@message)}\n\t</dd>\n" html << "</dl>" html << "<div>\n\t#{@files.map{ |diff| diff.to_html} }\n\t</div>\n" html << "</div>" html end |
#to_s ⇒ Object
149 150 151 |
# File 'lib/rgithook/githook.rb', line 149 def to_s "#{@commit[0..6]}... #{@message.split("\n")[0]}." end |