Class: FightClub::Merger
- Inherits:
-
Object
- Object
- FightClub::Merger
- Defined in:
- lib/fight_club/merger.rb
Instance Method Summary collapse
- #attempt_merge(pr) ⇒ Object
- #execute ⇒ Object
-
#initialize(base_pull, pr, git) ⇒ Merger
constructor
A new instance of Merger.
Constructor Details
#initialize(base_pull, pr, git) ⇒ Merger
Returns a new instance of Merger.
3 4 5 6 7 |
# File 'lib/fight_club/merger.rb', line 3 def initialize(base_pull, pr, git) @base_pull = base_pull @pr = pr @git = git end |
Instance Method Details
#attempt_merge(pr) ⇒ Object
26 27 28 29 30 |
# File 'lib/fight_club/merger.rb', line 26 def attempt_merge(pr) result = `#{FightClub.git_command} merge origin/#{pr.head.ref}` !(result.include? 'CONFLICT') end |
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fight_club/merger.rb', line 9 def execute Logger.new(STDOUT).info "Trying to merge #{pr.head.ref} into #{base_pull["head"]["ref"]}..." return unless pr.base.ref == FightClub.config.master_branch return if pr.head.ref == base_pull["head"]["ref"] git.reset_hard("origin/#{base_pull["head"]["ref"]}") git.checkout("origin/#{pr.head.ref}") return unless Rebaser.attempt_rebase(pr) git.checkout("origin/#{base_pull["head"]["ref"]}") unless attempt_merge(pr) Commenter.comment(pr, "Your branch currently conflicts with another open pull request: #{base_pull["_links"]["html"]["href"]}") Commenter.comment(base_pull, "Your branch currently conflicts with another open pull request: #{pr._links.html.href}") end end |