Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made review request emails contain commit message info

This inserts the last commits subject into the email subject,
and the body into the email body. This would help me to see
what people are doing, connecting review emails with in-person
discussions, etc
  • Loading branch information...
commit 70acb9f31384142f8d5663d6dbc3c5e889eb3b70 1 parent 9c4cf48
@woahdae woahdae authored
View
16 features/coder_requests_review.feature
@@ -30,22 +30,24 @@ Feature: Coder Requests Code Review
When I run "reviewr request reviewer@site.com"
Then reviewr should push "review_12345678" to origin
- Scenario: Send an email with a github compare URL
+ Scenario: Send an email with commit info and a github compare URL
Given the last commit was "12345678123456781234567812345678"
+ And the last commit subject was "Added subject to reviewr email"
+ And the last commit body was "Now you will see commit info in the review request"
And the origin is at "git@github.com:rhburrows/reviewr.git"
And the origin master commit is "87654321876543218765432187654321"
When I run "reviewr request reviewer@site.com"
- Then reviewr should send an email to "reviewer@site.com" with body:
+ Then reviewr should send an email to "reviewer@site.com"
+ And the subject of the sent email should be: "Code review request: Added subject to reviewr email"
+ And the body of the sent email should be:
"""
- Hi,
-
- Could you please code review and comment on the following changes:
+ Now you will see commit info in the review request
http://github.com/rhburrows/reviewr/compare/87654321...12345678
- If you find the changes acceptable please run:
+ Accept:
reviewr accept review_12345678
- If you think more work needs to be done please run:
+ Reject:
reviewr reject review_12345678
Thanks!
View
10 features/step_definitions/git_steps.rb
@@ -18,7 +18,15 @@
end
Given /^the last commit was "([^\"]*)"$/ do |commit|
- mock_git('git show --pretty=format:"%H" HEAD', commit)
+ mock_git(%(git show --pretty=format:"%H" HEAD), commit)
+end
+
+Given /^the last commit subject was "([^\"]*)"$/ do |commit|
+ mock_git(%(git show --pretty=format:"%s" HEAD^), commit)
+end
+
+Given /^the last commit body was "([^\"]*)"$/ do |commit|
+ mock_git(%(git show --pretty=format:"%b:::::" HEAD^), commit + ":::::")
end
Given /^the origin is at "([^\"]*)"$/ do |location|
View
12 features/step_definitions/reviewr_steps.rb
@@ -36,6 +36,18 @@
Pony.sent[:body].should == body
end
+Then /^reviewr should send an email to "([^\"]*)"$/ do |email|
+ Pony.sent[:to].should == email
+end
+
+Then /^the body of the sent email should be:$/ do |body|
+ Pony.sent[:body].should == body
+end
+
+Then /^the subject of the sent email should be: "(.*?)"$/ do |subject|
+ Pony.sent[:subject].should == subject
+end
+
Then /^reviewr should abort the acceptance$/ do
git_executed?("git rebase --abort").should be_true
end
View
16 lib/reviewr/git.rb
@@ -12,12 +12,20 @@ def instance=(instance)
attr_writer :remote_repo
- def remote_repo
- @remote_repo ||= "origin"
+ def last_commit_sha
+ execute(%(git show --pretty=format:"%H" HEAD)).split("\n").first
+ end
+
+ def last_commit_subject
+ execute(%(git show --pretty=format:"%s" HEAD^)).split("\n").first
end
- def last_commit
- execute('git show --pretty=format:"%H" HEAD').split("\n")[0]
+ def last_commit_body
+ execute(%(git show --pretty=format:"%b:::::" HEAD^)).split(":::::").first
+ end
+
+ def remote_repo
+ @remote_repo ||= "origin"
end
def rebase(base, branch)
View
2  lib/reviewr/mailer.rb
@@ -12,7 +12,7 @@ def send(body)
Pony.mail(:from => @project.user_email,
:to => @project.to,
:body => body,
- :subject => "Code review request from #{@project.user_email}",
+ :subject => "Code review request: #{@project.review_subject}",
:via => :smtp,
:smtp => {
:host => 'smtp.gmail.com',
View
10 lib/reviewr/project.rb
@@ -41,7 +41,15 @@ def push_review_branch
end
def review_sha
- @review_sha ||= git.last_commit.slice(0, 8)
+ @review_sha ||= git.last_commit_sha.slice(0, 8)
+ end
+
+ def review_subject
+ @review_subject ||= git.last_commit_subject
+ end
+
+ def review_body
+ @review_body ||= git.last_commit_body
end
def master_sha
View
8 lib/reviewr/templates/request_email.erb
@@ -1,12 +1,10 @@
-Hi,
-
-Could you please code review and comment on the following changes:
+<%= project.review_body %>
<%= compare_url %>
-If you find the changes acceptable please run:
+Accept:
reviewr accept <%= project.review_branch %>
-If you think more work needs to be done please run:
+Reject:
reviewr reject <%= project.review_branch %>
Thanks!
View
9 spec/reviewr/cli/request_spec.rb
@@ -80,15 +80,13 @@ module CLI
describe "#email_body" do
BODY= <<-END
-Hi,
-
-Could you please code review and comment on the following changes:
+The commit body is in the email
compare url
-If you find the changes acceptable please run:
+Accept:
reviewr accept review_12345678
-If you think more work needs to be done please run:
+Reject:
reviewr reject review_12345678
Thanks!
@@ -97,6 +95,7 @@ module CLI
it "generates the email body based on the project" do
request.stub(:compare_url).and_return("compare url")
project.stub(:review_branch).and_return("review_12345678")
+ project.stub(:review_body).and_return("The commit body is in the email")
request.email_body.should == BODY
end
end
View
24 spec/reviewr/git_spec.rb
@@ -8,16 +8,32 @@ module Reviewr
git.stub(:execute)
end
- describe "#last_commit" do
+ describe "#last_commit_sha" do
it "shells out to git to the get the hash of the last commit" do
git.stub!(:execute).and_return("")
git.should_receive(:execute).with('git show --pretty=format:"%H" HEAD')
- git.last_commit
+ git.last_commit_sha
end
it "cuts out the first line (sha)" do
- git.stub!(:execute).and_return("12345678\nblah\nblah\nblah")
- git.last_commit.should == "12345678"
+ git.stub!(:execute).and_return("12345678")
+ git.last_commit_sha.should == "12345678"
+ end
+ end
+
+ describe "#last_commit_subject" do
+ it "shells out to git to the get the subject of the last commit" do
+ git.stub!(:execute).and_return("")
+ git.should_receive(:execute).with('git show --pretty=format:"%s" HEAD^')
+ git.last_commit_subject
+ end
+ end
+
+ describe "#last_commit_body" do
+ it "shells out to git to the get the body of the last commit" do
+ git.stub!(:execute).and_return("")
+ git.should_receive(:execute).with('git show --pretty=format:"%b:::::" HEAD^')
+ git.last_commit_body
end
end
View
3  spec/reviewr/mailer_spec.rb
@@ -14,11 +14,12 @@ module Reviewr
mailer.project.stub(:to).and_return('to')
mailer.project.stub(:email_server).and_return('host')
mailer.project.stub(:email_password).and_return('p')
+ mailer.project.stub(:review_subject).and_return('Commit subject')
Pony.should_receive(:mail).with(
hash_including(:from => 'from',
:to => 'to',
:body => 'body',
- :subject => 'Code review request from from',
+ :subject => 'Code review request: Commit subject',
:via => :smtp,
:smtp => {
:host => 'smtp.gmail.com',
View
2  spec/reviewr/project_spec.rb
@@ -7,7 +7,7 @@ module Reviewr
describe "#review_sha" do
it "returns the first 8 characters of the last commit" do
- git.stub!(:last_commit).and_return('12345678123e324')
+ git.stub(:last_commit_sha).and_return('12345678123e324')
project.review_sha.should == '12345678'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.