Class: Yard::GHPages::BranchMerger
- Inherits:
-
Object
- Object
- Yard::GHPages::BranchMerger
- Defined in:
- lib/yard-ghpages/branch_merger.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#message ⇒ Object
Returns the value of attribute message.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(opts = {}) {|_self| ... } ⇒ BranchMerger
constructor
A new instance of BranchMerger.
- #merge ⇒ Object
- #push ⇒ Object
Constructor Details
#initialize(opts = {}) {|_self| ... } ⇒ BranchMerger
Returns a new instance of BranchMerger.
8 9 10 11 |
# File 'lib/yard-ghpages/branch_merger.rb', line 8 def initialize(opts = {}, &block) opts.each { |k, v| self.send("#{k.to_s}=", v) } yield(self) if block_given? end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
7 8 9 |
# File 'lib/yard-ghpages/branch_merger.rb', line 7 def destination @destination end |
#message ⇒ Object
Returns the value of attribute message.
7 8 9 |
# File 'lib/yard-ghpages/branch_merger.rb', line 7 def @message end |
#source ⇒ Object
Returns the value of attribute source.
7 8 9 |
# File 'lib/yard-ghpages/branch_merger.rb', line 7 def source @source end |
Instance Method Details
#merge ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yard-ghpages/branch_merger.rb', line 13 def merge git.reset source_tree = sha source[:branch], source[:directory] raise Exception.new("Could not find source #{source}") unless source_tree dest_commit = head_commit(destination[:branch]) commit = git.commit_tree(source_tree, message: , parents: dest_commit || nil ) git.update_ref(ref_head(destination[:branch]), commit) self end |
#push ⇒ Object
25 26 27 28 |
# File 'lib/yard-ghpages/branch_merger.rb', line 25 def push git.push('origin', destination[:branch]) self end |