Class: GTA::Diff
Constant Summary collapse
- DEFAULT_FORMAT =
'short'
Instance Attribute Summary collapse
-
#destination_name ⇒ Object
readonly
Returns the value of attribute destination_name.
-
#gta_config_path ⇒ Object
readonly
Returns the value of attribute gta_config_path.
-
#source_name ⇒ Object
readonly
Returns the value of attribute source_name.
Instance Method Summary collapse
- #cherry_pick ⇒ Object
- #destination ⇒ Object
-
#initialize(source_name, destination_name, gta_config_path = nil) ⇒ Diff
constructor
A new instance of Diff.
- #manager ⇒ Object
- #report(format = DEFAULT_FORMAT) ⇒ Object
- #shas ⇒ Object
- #source ⇒ Object
Methods included from Sh
Constructor Details
#initialize(source_name, destination_name, gta_config_path = nil) ⇒ Diff
Returns a new instance of Diff.
9 10 11 12 13 |
# File 'lib/gta/diff.rb', line 9 def initialize(source_name, destination_name, gta_config_path=nil) @source_name = source_name @destination_name = destination_name @gta_config_path = gta_config_path end |
Instance Attribute Details
#destination_name ⇒ Object (readonly)
Returns the value of attribute destination_name.
5 6 7 |
# File 'lib/gta/diff.rb', line 5 def destination_name @destination_name end |
#gta_config_path ⇒ Object (readonly)
Returns the value of attribute gta_config_path.
5 6 7 |
# File 'lib/gta/diff.rb', line 5 def gta_config_path @gta_config_path end |
#source_name ⇒ Object (readonly)
Returns the value of attribute source_name.
5 6 7 |
# File 'lib/gta/diff.rb', line 5 def source_name @source_name end |
Instance Method Details
#cherry_pick ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/gta/diff.rb', line 37 def cherry_pick commits = shas.split("\n") sh("git checkout #{destination.name}") commits.each do |sha| sh("git cherry-pick #{sha}") end end |
#destination ⇒ Object
23 24 25 |
# File 'lib/gta/diff.rb', line 23 def destination @destination ||= manager.stage!(destination_name) end |
#manager ⇒ Object
15 16 17 |
# File 'lib/gta/diff.rb', line 15 def manager @manager ||= Manager.new(gta_config_path) end |
#report(format = DEFAULT_FORMAT) ⇒ Object
27 28 29 30 31 |
# File 'lib/gta/diff.rb', line 27 def report(format=DEFAULT_FORMAT) source.fetch! destination.fetch! sh("git log #{source.name}/master..#{destination.name}/master --format=#{format}") end |
#shas ⇒ Object
33 34 35 |
# File 'lib/gta/diff.rb', line 33 def shas report('%h') end |
#source ⇒ Object
19 20 21 |
# File 'lib/gta/diff.rb', line 19 def source @source ||= manager.stage!(source_name) end |