Skip to content

Commit

Permalink
Added "From"-Field in config. Fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
bitboxer committed Oct 9, 2010
1 parent 704b66f commit cbb512a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
10 changes: 7 additions & 3 deletions config/git-notifier-config.yml.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# The recipient for the commit:
mailinglist: developers@example.com

# set to true if you want to ignore empty merge messages
ignore_merge: false

Expand All @@ -10,6 +7,13 @@ ignore_merge: false
# Limit lines per diff
# lines_per_diff: 300

# The recipient for the commit:
mailinglist: developers@example.com

# The from addres. If not defined it will use
# the address that is configured in git
# from: sender@example.com

# select the delivery method: smtp or sendmail
delivery_method: sendmail

Expand Down
6 changes: 4 additions & 2 deletions lib/commit_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def self.run(config, rev1, rev2, ref_name)
html << result[:html_content]
end
result = diffresult.first

emailer = Emailer.new(
@config,
project_path,
recipient,
result[:commit_info][:email],
@config["from"] || result[:commit_info][:email],
result[:commit_info][:author],
"[#{prefix}#{branch_name}] #{diffresult.size > 1 ? "#{diffresult.size} commits: " : ''}#{result[:commit_info][:message]}",
text.join("------------------------------------------\n\n"),
Expand All @@ -72,11 +73,12 @@ def self.run(config, rev1, rev2, ref_name)
else
diffresult.reverse.each_with_index do |result, i|
nr = number(diffresult.size, i)

emailer = Emailer.new(
@config,
project_path,
recipient,
result[:commit_info][:email],
@config["from"] || result[:commit_info][:email],
result[:commit_info][:author],
"[#{prefix}#{branch_name}]#{nr} #{result[:commit_info][:message]}",
result[:text_content],
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/git-notifier-group-email-by-push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
delivery_method: sendmail # smtp or sendmail
ignore_merge: false # set to true if you want to ignore empty merge messages

from: max@example.com

group_email_by_push: true

smtp_server:
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_commit_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def run_with_config(config, times)
CommitHook.run config, REVISIONS.first, REVISIONS.last, 'refs/heads/master'
end

def test_commit_from
# 1 commit with a from: adress
expect_repository_access
emailer = mock('Emailer')
Emailer.expects(:new).with(anything, anything, anything, "max@example.com", any_parameters).returns(emailer)
emailer.expects(:send)
CommitHook.run 'test/fixtures/git-notifier-group-email-by-push.yml', REVISIONS.first, REVISIONS.last, 'refs/heads/master'
end

def expect_repository_access
path = File.dirname(__FILE__) + '/../fixtures/'
Git.expects(:log).with(REVISIONS.first, REVISIONS.last).returns(read_file(path + 'git_log'))
Expand Down

0 comments on commit cbb512a

Please sign in to comment.