Class: Reviewr::CLI::Accept

Inherits:
Command
  • Object
show all
Defined in:
lib/reviewr/cli/accept.rb

Instance Attribute Summary

Attributes inherited from Command

#arguments, #input, #output, #project

Instance Method Summary collapse

Methods inherited from Command

#call, #initialize, #prompt_for_user, #read_template

Constructor Details

This class inherits a constructor from Reviewr::CLI::Command

Instance Method Details

#email_bodyObject



28
29
30
# File 'lib/reviewr/cli/accept.rb', line 28

def email_body
  read_template('accept_email.erb')
end

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/reviewr/cli/accept.rb', line 4

def execute
  merge_branch = project.current_branch

  project.review_branch = arguments.first
  prompt_for_user
  project.fetch_review_branch
  project.fetch_master
  project.create_review_branch("#{project.remote_repo}/#{arguments.first}")

  unless project.rebase_review
    output.print "Branch '#{arguments.first}' won't merge cleanly"
  else
    # This must be run while on the review branch
    project.to = project.requester_email

    project.change_branch(merge_branch)
    project.merge_commits
    project.push_branch(merge_branch)
    project.delete_remote_review_branch

    Mailer.new(project).send(email_body)
  end
end