Class: HockeyGerrit
- Inherits:
-
Object
- Object
- HockeyGerrit
- Defined in:
- lib/hockey_gerrit.rb,
lib/hockey_gerrit/version.rb
Constant Summary collapse
- VERSION =
'0.0.4'.freeze
Instance Attribute Summary collapse
-
#change ⇒ Object
Returns the value of attribute change.
-
#log ⇒ Object
Returns the value of attribute log.
-
#log_line ⇒ Object
Returns the value of attribute log_line.
-
#output_file ⇒ Object
Returns the value of attribute output_file.
-
#patch ⇒ Object
Returns the value of attribute patch.
Instance Method Summary collapse
- #assign_log ⇒ Object
- #change_line ⇒ Object
- #changes(gerrit) ⇒ Object
- #delete_file ⇒ Object
- #write ⇒ Object
- #write_file ⇒ Object
Instance Attribute Details
#change ⇒ Object
Returns the value of attribute change.
5 6 7 |
# File 'lib/hockey_gerrit.rb', line 5 def change @change end |
#log ⇒ Object
Returns the value of attribute log.
5 6 7 |
# File 'lib/hockey_gerrit.rb', line 5 def log @log end |
#log_line ⇒ Object
Returns the value of attribute log_line.
5 6 7 |
# File 'lib/hockey_gerrit.rb', line 5 def log_line @log_line end |
#output_file ⇒ Object
Returns the value of attribute output_file.
5 6 7 |
# File 'lib/hockey_gerrit.rb', line 5 def output_file @output_file end |
#patch ⇒ Object
Returns the value of attribute patch.
5 6 7 |
# File 'lib/hockey_gerrit.rb', line 5 def patch @patch end |
Instance Method Details
#assign_log ⇒ Object
13 14 15 16 |
# File 'lib/hockey_gerrit.rb', line 13 def assign_log @log = `git log --reverse -1 --format="%an: %s"` raise 'log command failed' unless $CHILD_STATUS.success? end |
#change_line ⇒ Object
26 27 28 29 30 31 |
# File 'lib/hockey_gerrit.rb', line 26 def change_line raise 'Change empty' if change.empty? raise 'Patch empty' if patch.empty? raise 'Log empty' if log.empty? @log_line = "g#{change},#{patch}\n#{log}" end |
#changes(gerrit) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/hockey_gerrit.rb', line 6 def changes(gerrit) raise 'No line from Gerrit provided' if gerrit.empty? gerrit_split = gerrit.split('/') raise 'ENV GERRIT_REFSPEC has invalid format' unless gerrit_split.size >= 2 @change, @patch = gerrit_split[-2..-1] end |
#delete_file ⇒ Object
22 23 24 |
# File 'lib/hockey_gerrit.rb', line 22 def delete_file File.delete(output_file) end |
#write ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/hockey_gerrit.rb', line 33 def write @output_file = 'changelog.md' raise 'ENV GERRIT_REFSPEC not defined' unless ENV['GERRIT_REFSPEC'] changes(ENV['GERRIT_REFSPEC']) assign_log change_line write_file end |
#write_file ⇒ Object
18 19 20 |
# File 'lib/hockey_gerrit.rb', line 18 def write_file File.write(output_file, log_line) end |