git-commit-notifier 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source :rubygems
2
+
3
+ gem 'diff-lcs'
4
+ gem 'nntp'
5
+ gem 'premailer', '~>1.7.1'
6
+ gem 'nokogiri'
7
+
8
+ group :development do
9
+ gem 'jeweler'
10
+ gem 'code-cleaner'
11
+ gem 'metric_fu'
12
+ end
13
+
14
+ group :test do
15
+ gem 'rspec-core'
16
+ gem 'rspec-expectations'
17
+ gem 'rr'
18
+ gem 'faker'
19
+ gem 'rcov'
20
+ end
21
+
data/Gemfile.lock ADDED
@@ -0,0 +1,105 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ Saikuro (1.1.0)
5
+ abstract (1.0.0)
6
+ activesupport (3.0.5)
7
+ arrayfields (4.7.4)
8
+ chronic (0.3.0)
9
+ churn (0.0.13)
10
+ chronic (>= 0.2.3)
11
+ hirb
12
+ json_pure
13
+ main
14
+ ruby_parser (~> 2.0.4)
15
+ sexp_processor (~> 3.0.3)
16
+ code-cleaner (0.8.2)
17
+ colored (1.2)
18
+ css_parser (1.1.9)
19
+ diff-lcs (1.1.2)
20
+ erubis (2.6.6)
21
+ abstract (>= 1.0.0)
22
+ faker (0.9.5)
23
+ i18n (~> 0.4)
24
+ fattr (2.2.0)
25
+ flay (1.4.2)
26
+ ruby_parser (~> 2.0)
27
+ sexp_processor (~> 3.0)
28
+ flog (2.5.1)
29
+ ruby_parser (~> 2.0)
30
+ sexp_processor (~> 3.0)
31
+ git (1.2.5)
32
+ haml (3.0.25)
33
+ hirb (0.4.3)
34
+ htmlentities (4.3.0)
35
+ i18n (0.5.0)
36
+ jeweler (1.5.2)
37
+ bundler (~> 1.0.0)
38
+ git (>= 1.2.5)
39
+ rake
40
+ json_pure (1.5.1)
41
+ main (4.4.0)
42
+ arrayfields (>= 4.7.4)
43
+ fattr (>= 2.1.0)
44
+ metric_fu (2.1.1)
45
+ Saikuro (>= 1.1.0)
46
+ activesupport (>= 2.0.0)
47
+ chronic (~> 0.3.0)
48
+ churn (>= 0.0.7)
49
+ flay (>= 1.2.1)
50
+ flog (>= 2.3.0)
51
+ rails_best_practices (>= 0.6.4)
52
+ rcov (>= 0.8.3.3)
53
+ reek (>= 1.2.6)
54
+ roodi (>= 2.1.0)
55
+ syntax
56
+ nntp (1.0.0)
57
+ nokogiri (1.4.4)
58
+ premailer (1.7.1)
59
+ css_parser (>= 1.1.9)
60
+ htmlentities (>= 4.0.0)
61
+ rails_best_practices (0.7.5)
62
+ activesupport
63
+ colored (~> 1.2)
64
+ erubis (~> 2.6.6)
65
+ haml (~> 3.0.18)
66
+ i18n
67
+ ruby-progressbar (~> 0.0.9)
68
+ ruby_parser (~> 2.0.4)
69
+ rake (0.8.7)
70
+ rcov (0.9.9)
71
+ reek (1.2.8)
72
+ ruby2ruby (~> 1.2)
73
+ ruby_parser (~> 2.0)
74
+ sexp_processor (~> 3.0)
75
+ roodi (2.1.0)
76
+ ruby_parser
77
+ rr (1.0.2)
78
+ rspec-core (2.5.1)
79
+ rspec-expectations (2.5.0)
80
+ diff-lcs (~> 1.1.2)
81
+ ruby-progressbar (0.0.9)
82
+ ruby2ruby (1.2.5)
83
+ ruby_parser (~> 2.0)
84
+ sexp_processor (~> 3.0)
85
+ ruby_parser (2.0.6)
86
+ sexp_processor (~> 3.0)
87
+ sexp_processor (3.0.5)
88
+ syntax (1.0.0)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ code-cleaner
95
+ diff-lcs
96
+ faker
97
+ jeweler
98
+ metric_fu
99
+ nntp
100
+ nokogiri
101
+ premailer (~> 1.7.1)
102
+ rcov
103
+ rr
104
+ rspec-core
105
+ rspec-expectations
data/README.textile CHANGED
@@ -5,7 +5,9 @@ __by Bodo Tasche (bodo 'at' wannawork 'dot' de), Akzhan Abdulin (akzhan 'dot' ab
5
5
  Sends email commit messages splitting commits that were pushed in one step.
6
6
  Email is delivered as text or HTML with changes refined per word. Emails
7
7
  have a scanable subject containing the first sentence of the commit as well
8
- as the author, project and branch name.
8
+ as the author, project and branch name.
9
+
10
+ It's also possible to send a mail to a newsgroup using NNTP.
9
11
 
10
12
  For example:
11
13
 
@@ -85,6 +87,9 @@ You should not receive messages about commits those already posted in other bran
85
87
  This behaviour can be changed using unique_commits_per_branch option. When it's true,
86
88
  you should receive new message about commit when it's merged in other branch.
87
89
 
90
+ Yet another option, skip_commits_older_than (in days), should be used to not inform about
91
+ old commits in processes of forking, branching etc.
92
+
88
93
  h2. Note on Patches/Pull Requests
89
94
 
90
95
  * Fork the project.
data/Rakefile CHANGED
@@ -13,9 +13,9 @@ begin
13
13
  gem.homepage = "http://github.com/bitboxer/git-commit-notifier"
14
14
  gem.authors = ["Bodo Tasche"]
15
15
  gem.add_dependency('diff-lcs')
16
- gem.add_dependency('mocha')
17
- gem.add_dependency('hpricot')
18
- gem.add_dependency('tamtam')
16
+ gem.add_dependency('nntp')
17
+ gem.add_dependency('premailer', '~>1.7.1')
18
+ gem.add_dependency('nokogiri')
19
19
  gem.add_development_dependency('rspec-core')
20
20
  gem.add_development_dependency('rspec-expectations')
21
21
  gem.add_development_dependency('rr')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.9.0
@@ -9,7 +9,9 @@ end
9
9
  # parameters: revision1, revision 2, branch
10
10
  THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
11
11
  $:.unshift File.join(File.dirname(THIS_FILE), "../lib")
12
- require "commit_hook"
12
+
13
+ require 'git_commit_notifier'
14
+ include GitCommitNotifier
13
15
 
14
16
  case ARGV.length
15
17
  when 0
@@ -7,8 +7,13 @@ ignore_merge: false
7
7
  # Limit lines per diff
8
8
  # lines_per_diff: 300
9
9
 
10
- # The recipient for the commit:
11
- mailinglist: developers@example.com
10
+ # defines what branches to email for (defaults to all)
11
+ # include_branches: master
12
+ # include_branches: [master,some_other_branch]
13
+
14
+ # The recipient (or newsgroup for nntp) for the commit
15
+ # It can send to multiple destination, just seperate email address by "," :
16
+ mailinglist: developers@example.com,dev2@example.com,dev3@example.com,cto@example.com
12
17
 
13
18
  # The from addres. If not defined it will use
14
19
  # the address that is configured in git
@@ -17,7 +22,7 @@ mailinglist: developers@example.com
17
22
  # stylesheet file (embedded template/styles.css by default)
18
23
  # stylesheet: /absolute/path/to/readable/stylesheet.css
19
24
 
20
- # select the delivery method: smtp or sendmail
25
+ # select the delivery method: smtp, nntp, or sendmail
21
26
  delivery_method: sendmail
22
27
 
23
28
  # Optionally group email by push: don't send an email for each commit when true.
@@ -33,11 +38,27 @@ smtp_server:
33
38
  authentication: plain
34
39
  enable_tls: false
35
40
 
41
+ # settings for the tls smtp server (gmail,etc)
42
+ # If you use gmail, just uncomment follow section and configure password
43
+ #smtp_server:
44
+ # address: smtp.gmail.com
45
+ # port: 587
46
+ # domain: smtp.gmail.com
47
+ # user_name: username@gmail.com
48
+ # password: password
49
+ # authentication: plain
50
+ # enable_tls: true
51
+
36
52
  # settings for sendmail
37
53
  sendmail_options:
38
54
  location: /usr/sbin/sendmail
39
55
  arguments: -i -t
40
56
 
57
+ # settings for nntp/newsgroup
58
+ nntp_settings:
59
+ address: your.nntp.host.here
60
+ port: 119
61
+
41
62
  # Decorate files and commit ids with link to a webview. Possible values: none, gitweb, gitorious, cgit or trac
42
63
  link_files: none
43
64
 
@@ -78,8 +99,11 @@ message_integration:
78
99
  # Track unique commits per branch?
79
100
  unique_commits_per_branch: false
80
101
 
102
+ # Skip commits older than N days
103
+ skip_commits_older_than: 7
104
+
81
105
  # This is developer debugging options. Do not uncomment it if You aren't Jedi
82
106
  # debug:
83
- # enable: true
107
+ # enabled: true
84
108
  # log_directory: /path/to/log/directory
85
109
 
@@ -1,74 +1,78 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{git-commit-notifier}
8
- s.version = "0.8.1"
8
+ s.version = "0.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bodo Tasche"]
12
- s.date = %q{2010-11-03}
12
+ s.date = %q{2011-04-04}
13
13
  s.default_executable = %q{git-commit-notifier}
14
14
  s.description = %q{This git commit notifier sends html mails with nice diffs for every changed file.}
15
15
  s.email = %q{bodo@bitboxer.de}
16
16
  s.executables = ["git-commit-notifier"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.textile"
19
+ "README.textile"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
- ".gitignore",
24
- "LICENSE",
25
- "README.textile",
26
- "Rakefile",
27
- "VERSION",
28
- "bin/git-commit-notifier",
29
- "config/git-notifier-config.yml.sample",
30
- "git-commit-notifier.gemspec",
31
- "lib/commit_hook.rb",
32
- "lib/diff_to_html.rb",
33
- "lib/emailer.rb",
34
- "lib/git.rb",
35
- "lib/logger.rb",
36
- "lib/result_processor.rb",
37
- "spec/fixtures/existing_file_one_line.txt",
38
- "spec/fixtures/git-notifier-group-email-by-push.yml",
39
- "spec/fixtures/git-notifier-ignore-merge.yml",
40
- "spec/fixtures/git-notifier-with-merge.yml",
41
- "spec/fixtures/git_log",
42
- "spec/fixtures/git_show_055850e7d925110322b8db4e17c3b840d76e144c",
43
- "spec/fixtures/git_show_51b986619d88f7ba98be7d271188785cbbb541a0",
44
- "spec/fixtures/git_show_a4629e707d80a5769f7a71ca6ed9471015e14dc9",
45
- "spec/fixtures/git_show_dce6ade4cdc2833b53bd600ef10f9bce83c7102d",
46
- "spec/fixtures/git_show_e28ad77bba0574241e6eb64dfd0c1291b221effe",
47
- "spec/fixtures/git_show_ff037a73fc1094455e7bbf506171a3f3cf873ae6",
48
- "spec/fixtures/new_file_one_line.txt",
49
- "spec/lib/commit_hook_spec.rb",
50
- "spec/lib/diff_to_html_spec.rb",
51
- "spec/lib/emailer_spec.rb",
52
- "spec/lib/git_spec.rb",
53
- "spec/lib/logger_spec.rb",
54
- "spec/lib/result_processor_spec.rb",
55
- "spec/spec_helper.rb",
56
- "template/email.html.erb",
57
- "template/styles.css"
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE",
26
+ "README.textile",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/git-commit-notifier",
30
+ "config/git-notifier-config.yml.sample",
31
+ "git-commit-notifier.gemspec",
32
+ "lib/git_commit_notifier.rb",
33
+ "lib/git_commit_notifier/commit_hook.rb",
34
+ "lib/git_commit_notifier/diff_callback.rb",
35
+ "lib/git_commit_notifier/diff_to_html.rb",
36
+ "lib/git_commit_notifier/emailer.rb",
37
+ "lib/git_commit_notifier/escape_helper.rb",
38
+ "lib/git_commit_notifier/git.rb",
39
+ "lib/git_commit_notifier/logger.rb",
40
+ "lib/git_commit_notifier/result_processor.rb",
41
+ "spec/fixtures/existing_file_one_line.txt",
42
+ "spec/fixtures/git-notifier-group-email-by-push.yml",
43
+ "spec/fixtures/git-notifier-ignore-merge.yml",
44
+ "spec/fixtures/git-notifier-with-branch-restrictions.yml",
45
+ "spec/fixtures/git-notifier-with-merge.yml",
46
+ "spec/fixtures/git_log",
47
+ "spec/fixtures/git_show_055850e7d925110322b8db4e17c3b840d76e144c",
48
+ "spec/fixtures/git_show_51b986619d88f7ba98be7d271188785cbbb541a0",
49
+ "spec/fixtures/git_show_a4629e707d80a5769f7a71ca6ed9471015e14dc9",
50
+ "spec/fixtures/git_show_dce6ade4cdc2833b53bd600ef10f9bce83c7102d",
51
+ "spec/fixtures/git_show_e28ad77bba0574241e6eb64dfd0c1291b221effe",
52
+ "spec/fixtures/git_show_ff037a73fc1094455e7bbf506171a3f3cf873ae6",
53
+ "spec/fixtures/new_file_one_line.txt",
54
+ "spec/lib/git_commit_notifier/commit_hook_spec.rb",
55
+ "spec/lib/git_commit_notifier/diff_to_html_spec.rb",
56
+ "spec/lib/git_commit_notifier/emailer_spec.rb",
57
+ "spec/lib/git_commit_notifier/git_spec.rb",
58
+ "spec/lib/git_commit_notifier/logger_spec.rb",
59
+ "spec/lib/git_commit_notifier/result_processor_spec.rb",
60
+ "spec/spec_helper.rb",
61
+ "template/email.html.erb",
62
+ "template/styles.css"
58
63
  ]
59
64
  s.homepage = %q{http://github.com/bitboxer/git-commit-notifier}
60
- s.rdoc_options = ["--charset=UTF-8"]
61
65
  s.require_paths = ["lib"]
62
66
  s.rubygems_version = %q{1.3.7}
63
67
  s.summary = %q{Sends git commit messages with diffs}
64
68
  s.test_files = [
65
- "spec/lib/commit_hook_spec.rb",
66
- "spec/lib/diff_to_html_spec.rb",
67
- "spec/lib/emailer_spec.rb",
68
- "spec/lib/git_spec.rb",
69
- "spec/lib/logger_spec.rb",
70
- "spec/lib/result_processor_spec.rb",
71
- "spec/spec_helper.rb"
69
+ "spec/lib/git_commit_notifier/commit_hook_spec.rb",
70
+ "spec/lib/git_commit_notifier/diff_to_html_spec.rb",
71
+ "spec/lib/git_commit_notifier/emailer_spec.rb",
72
+ "spec/lib/git_commit_notifier/git_spec.rb",
73
+ "spec/lib/git_commit_notifier/logger_spec.rb",
74
+ "spec/lib/git_commit_notifier/result_processor_spec.rb",
75
+ "spec/spec_helper.rb"
72
76
  ]
73
77
 
74
78
  if s.respond_to? :specification_version then
@@ -77,9 +81,16 @@ Gem::Specification.new do |s|
77
81
 
78
82
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
79
83
  s.add_runtime_dependency(%q<diff-lcs>, [">= 0"])
80
- s.add_runtime_dependency(%q<mocha>, [">= 0"])
81
- s.add_runtime_dependency(%q<hpricot>, [">= 0"])
82
- s.add_runtime_dependency(%q<tamtam>, [">= 0"])
84
+ s.add_runtime_dependency(%q<nntp>, [">= 0"])
85
+ s.add_runtime_dependency(%q<premailer>, ["~> 1.7.1"])
86
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
87
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
88
+ s.add_development_dependency(%q<code-cleaner>, [">= 0"])
89
+ s.add_development_dependency(%q<metric_fu>, [">= 0"])
90
+ s.add_runtime_dependency(%q<diff-lcs>, [">= 0"])
91
+ s.add_runtime_dependency(%q<nntp>, [">= 0"])
92
+ s.add_runtime_dependency(%q<premailer>, ["~> 1.7.1"])
93
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
83
94
  s.add_development_dependency(%q<rspec-core>, [">= 0"])
84
95
  s.add_development_dependency(%q<rspec-expectations>, [">= 0"])
85
96
  s.add_development_dependency(%q<rr>, [">= 0"])
@@ -88,9 +99,16 @@ Gem::Specification.new do |s|
88
99
  s.add_development_dependency(%q<metric_fu>, [">= 0"])
89
100
  else
90
101
  s.add_dependency(%q<diff-lcs>, [">= 0"])
91
- s.add_dependency(%q<mocha>, [">= 0"])
92
- s.add_dependency(%q<hpricot>, [">= 0"])
93
- s.add_dependency(%q<tamtam>, [">= 0"])
102
+ s.add_dependency(%q<nntp>, [">= 0"])
103
+ s.add_dependency(%q<premailer>, ["~> 1.7.1"])
104
+ s.add_dependency(%q<nokogiri>, [">= 0"])
105
+ s.add_dependency(%q<jeweler>, [">= 0"])
106
+ s.add_dependency(%q<code-cleaner>, [">= 0"])
107
+ s.add_dependency(%q<metric_fu>, [">= 0"])
108
+ s.add_dependency(%q<diff-lcs>, [">= 0"])
109
+ s.add_dependency(%q<nntp>, [">= 0"])
110
+ s.add_dependency(%q<premailer>, ["~> 1.7.1"])
111
+ s.add_dependency(%q<nokogiri>, [">= 0"])
94
112
  s.add_dependency(%q<rspec-core>, [">= 0"])
95
113
  s.add_dependency(%q<rspec-expectations>, [">= 0"])
96
114
  s.add_dependency(%q<rr>, [">= 0"])
@@ -100,9 +118,16 @@ Gem::Specification.new do |s|
100
118
  end
101
119
  else
102
120
  s.add_dependency(%q<diff-lcs>, [">= 0"])
103
- s.add_dependency(%q<mocha>, [">= 0"])
104
- s.add_dependency(%q<hpricot>, [">= 0"])
105
- s.add_dependency(%q<tamtam>, [">= 0"])
121
+ s.add_dependency(%q<nntp>, [">= 0"])
122
+ s.add_dependency(%q<premailer>, ["~> 1.7.1"])
123
+ s.add_dependency(%q<nokogiri>, [">= 0"])
124
+ s.add_dependency(%q<jeweler>, [">= 0"])
125
+ s.add_dependency(%q<code-cleaner>, [">= 0"])
126
+ s.add_dependency(%q<metric_fu>, [">= 0"])
127
+ s.add_dependency(%q<diff-lcs>, [">= 0"])
128
+ s.add_dependency(%q<nntp>, [">= 0"])
129
+ s.add_dependency(%q<premailer>, ["~> 1.7.1"])
130
+ s.add_dependency(%q<nokogiri>, [">= 0"])
106
131
  s.add_dependency(%q<rspec-core>, [">= 0"])
107
132
  s.add_dependency(%q<rspec-expectations>, [">= 0"])
108
133
  s.add_dependency(%q<rr>, [">= 0"])
@@ -0,0 +1,8 @@
1
+ require 'git_commit_notifier/commit_hook'
2
+ require 'git_commit_notifier/diff_to_html'
3
+ require 'git_commit_notifier/diff_callback'
4
+ require 'git_commit_notifier/emailer'
5
+ require 'git_commit_notifier/escape_helper'
6
+ require 'git_commit_notifier/git'
7
+ require 'git_commit_notifier/logger'
8
+ require 'git_commit_notifier/result_processor'
@@ -0,0 +1,130 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ require 'cgi'
4
+ require 'net/smtp'
5
+ require 'digest/sha1'
6
+
7
+ module GitCommitNotifier
8
+ class CommitHook
9
+
10
+ class << self
11
+ attr_reader :config
12
+
13
+ def show_error(message)
14
+ $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
15
+ $stderr.puts "\n"
16
+ $stderr.puts message
17
+ $stderr.puts "\n"
18
+ $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
19
+ end
20
+
21
+ def info(message)
22
+ $stdout.puts message
23
+ $stdout.flush
24
+ end
25
+
26
+ def logger
27
+ @logger ||= Logger.new(config)
28
+ end
29
+
30
+ def run(config_name, rev1, rev2, ref_name)
31
+ @config = File.exists?(config_name) ? YAML::load_file(config_name) : {}
32
+
33
+ project_path = Dir.getwd
34
+ recipient = config["mailinglist"] || Git.mailing_list_address
35
+
36
+ if recipient.nil? || recipient.length == 0
37
+ GitCommitNotifier::CommitHook.show_error(
38
+ "Please add a recipient for the emails. Eg : \n" +
39
+ " git config hooks.mailinglist developer@example.com"
40
+ )
41
+ return
42
+ end
43
+
44
+ include_branches = config["include_branches"]
45
+
46
+ logger.debug('----')
47
+ logger.debug("pwd: #{Dir.pwd}")
48
+ logger.debug("ref_name: #{ref_name}")
49
+ logger.debug("rev1: #{rev1}")
50
+ logger.debug("rev2: #{rev2}")
51
+ logger.debug("included branches: #{include_branches.join(',')}") unless include_branches.nil?
52
+
53
+ prefix = @config["emailprefix"] || Git.repo_name
54
+ branch_name = ref_name.split("/").last
55
+
56
+ logger.debug("prefix: #{prefix}")
57
+ logger.debug("branch: #{branch_name}")
58
+
59
+ unless include_branches.nil? || include_branches.include?(branch_name)
60
+ info("Supressing mail for branch #{branch_name}...")
61
+ return
62
+ end
63
+
64
+ branch_name = branch_name.eql?('master') ? "" : "/#{branch_name}"
65
+
66
+ info("Sending mail...")
67
+
68
+ diff2html = GitCommitNotifier::DiffToHtml.new(Dir.pwd, config)
69
+ diff2html.diff_between_revisions(rev1, rev2, prefix, ref_name)
70
+
71
+ diffresult = diff2html.result
72
+
73
+ if config["ignore_merge"]
74
+ diffresult = diffresult.reject do |result|
75
+ !result[:commit_info][:merge].nil?
76
+ end
77
+ end
78
+
79
+ if config["group_email_by_push"]
80
+ text, html = [], []
81
+ diffresult.each_with_index do |result, i|
82
+ text << result[:text_content]
83
+ html << result[:html_content]
84
+ end
85
+ result = diffresult.first
86
+ return if result.nil? || !result[:commit_info]
87
+
88
+ emailer = GitCommitNotifier::Emailer.new(config,
89
+ :project_path => project_path,
90
+ :recipient => recipient,
91
+ :from_address => config["from"] || result[:commit_info][:email],
92
+ :from_alias => result[:commit_info][:author],
93
+ :subject => "[#{prefix}#{branch_name}] #{diffresult.size > 1 ? "#{diffresult.size} commits: " : ''}#{result[:commit_info][:message]}",
94
+ :text_message => text.join("------------------------------------------\n\n"),
95
+ :html_message => html.join("<hr /><br />"),
96
+ :old_rev => rev1,
97
+ :new_rev => rev2,
98
+ :ref_name => ref_name
99
+ )
100
+ emailer.send
101
+ else
102
+ diffresult.reverse.each_with_index do |result, i|
103
+ next unless result[:commit_info]
104
+ nr = number(diffresult.size, i)
105
+
106
+ emailer = GitCommitNotifier::Emailer.new(config,
107
+ :project_path => project_path,
108
+ :recipient => recipient,
109
+ :from_address => config["from"] || result[:commit_info][:email],
110
+ :from_alias => result[:commit_info][:author],
111
+ :subject => "[#{prefix}#{branch_name}]#{nr} #{result[:commit_info][:message]}",
112
+ :text_message => result[:text_content],
113
+ :html_message => result[:html_content],
114
+ :old_rev => rev1,
115
+ :new_rev => rev2,
116
+ :ref_name => ref_name
117
+ )
118
+ emailer.send
119
+ end
120
+ end
121
+ end
122
+
123
+ def number(total_entries, i)
124
+ return '' if total_entries <= 1
125
+ digits = total_entries < 10 ? 1 : 3
126
+ '[' + sprintf("%0#{digits}d", i + 1) + ']'
127
+ end
128
+ end
129
+ end
130
+ end