git-commit-notifier 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.2
1
+ 0.11.3
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  s.add_development_dependency(%q<rspec-expectations>, [">= 0"])
37
37
  s.add_development_dependency(%q<rr>, ["~> 1.0"])
38
38
  s.add_development_dependency(%q<faker>, ["~> 0.9.5"])
39
- s.add_development_dependency(%q<yard>, ["~> 0.7.4"])
39
+ s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
40
40
  s.add_development_dependency(%q<redcarpet>, ["~> 1.17.2"])
41
41
  end
42
42
 
@@ -6,28 +6,43 @@ require 'net/smtp'
6
6
  require 'digest/sha1'
7
7
 
8
8
  module GitCommitNotifier
9
+ # Represents Git commit hook handler.
9
10
  class CommitHook
10
11
 
11
12
  class << self
12
- attr_reader :config
13
+ # Configuration that read from YAML file.
14
+ # @return [Hash] Configuration.
15
+ attr_reader :config
13
16
 
17
+ # Prints error message to $stderr.
18
+ # @param [String] message Message to be printed to $stderr.
19
+ # @return [NilClass] nil
14
20
  def show_error(message)
15
21
  $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
16
22
  $stderr.puts "\n"
17
23
  $stderr.puts message
18
24
  $stderr.puts "\n"
19
25
  $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
26
+ nil
20
27
  end
21
28
 
29
+ # Prints informational message to $stdout.
30
+ # @param [String] message Message to be printed to $stdout.
31
+ # @return [NilClass] nil
22
32
  def info(message)
23
33
  $stdout.puts message
24
34
  $stdout.flush
35
+ nil
25
36
  end
26
37
 
38
+ # Gets logger.
27
39
  def logger
28
40
  @logger ||= Logger.new(config)
29
41
  end
30
42
 
43
+ # Gets list of branches from {config} to include into notifications.
44
+ # @note All branches will be notified about if returned list is nil; otherwise only specified branches will be notifified about.
45
+ # @return [Array(String), NilClass] Array of branches to include into notifications or nil.
31
46
  def include_branches
32
47
  include_branches = config["include_branches"]
33
48
  unless include_branches.nil?
@@ -39,19 +54,28 @@ module GitCommitNotifier
39
54
  include_branches
40
55
  end
41
56
 
42
- def merge_commit?(result)
43
- ! result[:commit_info][:merge].nil?
57
+ # Is merge commit?
58
+ # @param [Hash] commit_info Information about commit.
59
+ def merge_commit?(commit_info)
60
+ ! commit_info[:commit_info][:merge].nil?
44
61
  end
45
62
 
63
+ # Runs comit hook handler using specified arguments.
64
+ # @param [String] config_name Path to the application configuration file in YAML format.
65
+ # @param [String] rev1 First specified revision.
66
+ # @param [String] rev2 Second specified revision.
67
+ # @param [String] ref_name Git reference (usually in "refs/heads/branch" format).
68
+ # @return [NilClass] nil
69
+ # @see config
46
70
  def run(config_name, rev1, rev2, ref_name)
47
-
48
- # Load the configuration
71
+
72
+ # Load the configuration
49
73
  @config = File.exists?(config_name) ? YAML::load_file(config_name) : {}
50
74
 
51
75
  project_path = Git.git_dir
52
76
  repo_name = Git.repo_name
53
77
  prefix = config["emailprefix"] || repo_name
54
-
78
+
55
79
  branch_name = if ref_name =~ /^refs\/heads\/(.+)$/
56
80
  $1
57
81
  else
@@ -60,7 +84,7 @@ module GitCommitNotifier
60
84
  slash_branch_name = "/#{branch_name}"
61
85
  slash_branch_name = "" if !config["show_master_branch_name"] && slash_branch_name == '/master'
62
86
 
63
- # Identify email recipients
87
+ # Identify email recipients
64
88
  recipient = config["mailinglist"] || Git.mailing_list_address
65
89
 
66
90
  # If no recipients specified, bail out gracefully. This is not an error, and might be intentional
@@ -69,7 +93,7 @@ module GitCommitNotifier
69
93
  return
70
94
  end
71
95
 
72
- # Debug information
96
+ # Debug information
73
97
  logger.debug('----')
74
98
  logger.debug("cwd: #{Dir.pwd}")
75
99
  logger.debug("Git Directory: #{project_path}")
@@ -84,9 +108,9 @@ module GitCommitNotifier
84
108
 
85
109
  unless include_branches.nil? || include_branches.include?(branch_name)
86
110
  info("Supressing mail for branch #{branch_name}...")
87
- return
111
+ return nil
88
112
  end
89
-
113
+
90
114
  # Replacements for subject template
91
115
  # prefix
92
116
  # repo_name
@@ -110,7 +134,7 @@ module GitCommitNotifier
110
134
  :commit_count_phrase => nil,
111
135
  :commit_count_phrase2 => nil
112
136
  }
113
-
137
+
114
138
  info("Sending mail...")
115
139
 
116
140
  diff2html = DiffToHtml.new(config)
@@ -133,7 +157,7 @@ module GitCommitNotifier
133
157
  text << result[:text_content]
134
158
  html << result[:html_content]
135
159
  end
136
-
160
+
137
161
  # Form the subject from template
138
162
  revised_subject_words = subject_words.merge({
139
163
  :commit_id => result[:commit_info][:commit],
@@ -152,6 +176,7 @@ module GitCommitNotifier
152
176
  :from_address => config["from"] || result[:commit_info][:email],
153
177
  :from_alias => result[:commit_info][:author],
154
178
  :subject => subject,
179
+ :date => result[:commit_info][:date],
155
180
  :text_message => text.join("------------------------------------------\n\n"),
156
181
  :html_message => html.join("<hr /><br />"),
157
182
  :old_rev => rev1,
@@ -163,8 +188,8 @@ module GitCommitNotifier
163
188
  else
164
189
  commit_number = 1
165
190
  diff2html.diff_between_revisions(rev1, rev2, prefix, ref_name) do |result|
166
- next if config["ignore_merge"] && merge_commit?(result)
167
-
191
+ next if config["ignore_merge"] && merge_commit?(result)
192
+
168
193
  # Form the subject from template
169
194
  revised_subject_words = subject_words.merge({
170
195
  :commit_id => result[:commit_info][:commit],
@@ -176,13 +201,14 @@ module GitCommitNotifier
176
201
  })
177
202
  subject_template = config['subject'] || "[${prefix}${slash_branch_name}][${commit_number}] ${message}"
178
203
  subject = subject_template.gsub(/\$\{(\w+)\}/) { |m| revised_subject_words[$1.intern] }
179
-
204
+
180
205
  emailer = Emailer.new(config,
181
206
  :project_path => project_path,
182
207
  :recipient => recipient,
183
208
  :from_address => config["from"] || result[:commit_info][:email],
184
209
  :from_alias => result[:commit_info][:author],
185
210
  :subject => subject,
211
+ :date => result[:commit_info][:date],
186
212
  :text_message => result[:text_content],
187
213
  :html_message => result[:html_content],
188
214
  :old_rev => rev1,
@@ -194,11 +220,16 @@ module GitCommitNotifier
194
220
  commit_number += 1
195
221
  end
196
222
  end
223
+ nil
197
224
  end
198
225
 
226
+ # Gets human readable commit number.
227
+ # @param [Fixnum] i Commit index.
228
+ # @return [String] Human readable commit number.
199
229
  def number(i)
200
230
  "[#{i + 1}]"
201
231
  end
202
232
  end
203
233
  end
204
234
  end
235
+
@@ -1,24 +1,30 @@
1
1
  # -*- coding: utf-8; mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:filetype=ruby:et:sw=2:ts=2:sts=2
2
2
 
3
3
  module GitCommitNotifier
4
+ # Callback for Diff::LCS.traverse_balanced method.
4
5
  class DiffCallback
6
+ # Gets collected tags.
7
+ # @return [Array(Hash)] Collected tags.
5
8
  attr_reader :tags
6
9
 
7
10
  def initialize
8
11
  @tags = []
9
12
  end
10
13
 
14
+ # Adds diff match to {#tags}.
11
15
  def match(event)
12
16
  @tags << { :action => :match, :token => event.old_element }
13
17
  end
14
18
 
19
+ # Adds discarded B side to {#tags}.
15
20
  def discard_b(event)
16
21
  @tags << { :action => :discard_b, :token => event.new_element }
17
22
  end
18
23
 
24
+ # Adds discarded A side to {#tags}.
19
25
  def discard_a(event)
20
26
  @tags << { :action => :discard_a, :token => event.old_element }
21
27
  end
22
-
23
28
  end
24
29
  end
30
+
@@ -7,9 +7,11 @@ require 'time'
7
7
  require 'git_commit_notifier/escape_helper'
8
8
 
9
9
  module GitCommitNotifier
10
+ # Translates Git diff to HTML format
10
11
  class DiffToHtml
11
12
  include EscapeHelper
12
13
 
14
+ # Integration map for commit message keywords to third-party links.
13
15
  INTEGRATION_MAP = {
14
16
  :mediawiki => { :search_for => /\[\[([^\[\]]+)\]\]/, :replace_with => '#{url}/\1' },
15
17
  :redmine => {
@@ -32,11 +34,9 @@ module GitCommitNotifier
32
34
  :bugzilla => { :search_for => /\bBUG\s*(\d+)/i, :replace_with => '#{url}/show_bug.cgi?id=\1' },
33
35
  :fogbugz => { :search_for => /\bbugzid:\s*(\d+)/i, :replace_with => '#{url}\1' }
34
36
  }.freeze
37
+ # Maximum email line length in characters.
35
38
  MAX_LINE_LENGTH = 512
36
- MAX_COMMITS_PER_ACTION = 10000
37
- HANDLED_COMMITS_FILE = 'previously.txt'.freeze
38
- NEW_HANDLED_COMMITS_FILE = 'previously_new.txt'.freeze
39
- GIT_CONFIG_FILE = File.join('.git', 'config').freeze
39
+ # Number of seconds per day.
40
40
  SECS_PER_DAY = 24 * 60 * 60
41
41
 
42
42
  attr_accessor :file_prefix, :current_file_name
@@ -55,11 +55,13 @@ module GitCommitNotifier
55
55
  matches[1..2].map { |m| m.split(',')[0].to_i }
56
56
  end
57
57
 
58
+ # Gets HTML class for specified diff line data.
59
+ # @param [Hash] line Diff line data
58
60
  def line_class(line)
59
61
  case line[:op]
60
- when :removal then ' class="r"'
61
- when :addition then ' class="a"'
62
- else ''
62
+ when :removal; ' class="r"'
63
+ when :addition; ' class="a"'
64
+ else ''
63
65
  end
64
66
  end
65
67
 
@@ -70,20 +72,29 @@ module GitCommitNotifier
70
72
  end
71
73
  end
72
74
 
75
+ # Gets lines_per_diff setting from {#config}.
73
76
  def lines_per_diff
74
77
  @config['lines_per_diff']
75
78
  end
76
79
 
80
+ # Gets ignore_whitespace setting from {#config}.
81
+ # @return [Boolean] true if whitespaces should be ignored in diff; otherwise false.
77
82
  def ignore_whitespaces?
78
83
  @config['ignore_whitespace'].nil? || @config['ignore_whitespace']
79
84
  end
80
85
 
86
+ # Adds separator between diff blocks to @diff_result.
87
+ # @return [NilClass] nil
81
88
  def add_separator
82
89
  @diff_result << '<tr class="sep"><td class="sep" colspan="3" title="Unchanged content skipped between diff. blocks">&hellip;</td></tr>'
90
+ nil
83
91
  end
84
92
 
93
+ # Adds notification to @diff_result about skipping of diff tail due to its large size.
94
+ # @return [NilClass] nil
85
95
  def add_skip_notification
86
96
  @diff_result << '<tr><td colspan="3">Diff too large and stripped&hellip;</td></tr>'
97
+ nil
87
98
  end
88
99
 
89
100
  def add_line_to_result(line, escape)
@@ -127,6 +138,9 @@ module GitCommitNotifier
127
138
  result
128
139
  end
129
140
 
141
+ # Gets array of tokens from specified str.
142
+ # @param [String] str Text to be splitted into tokens.
143
+ # @return [Array(String)] Array of tokens.
130
144
  def tokenize_string(str)
131
145
  # tokenize by non-word characters
132
146
  tokens = []
@@ -157,11 +171,11 @@ module GitCommitNotifier
157
171
  end
158
172
 
159
173
  file_name = @current_file_name
160
-
174
+
161
175
  # TODO: these filenames, etc, should likely be properly html escaped
162
176
  if config['link_files']
163
177
  file_name = if config["link_files"] == "gitweb" && config["gitweb"]
164
- "<a href='#{config['gitweb']['path']}?p=#{Git.repo_name}.git;f=#{file_name};h=#{@current_sha};hb=#{@current_commit}'>#{file_name}</a>"
178
+ "<a href='#{config['gitweb']['path']}?p=#{config['gitweb']['project'] || "#{Git.repo_name}.git"};f=#{file_name};h=#{@current_sha};hb=#{@current_commit}'>#{file_name}</a>"
165
179
  elsif config["link_files"] == "gitorious" && config["gitorious"]
166
180
  "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/blobs/#{branch_name}/#{file_name}'>#{file_name}</a>"
167
181
  elsif config["link_files"] == "cgit" && config["cgit"]
@@ -183,6 +197,8 @@ module GitCommitNotifier
183
197
  "<h2>#{header}</h2>\n"
184
198
  end
185
199
 
200
+ # Determines are two lines are sequentially placed in diff (no skipped lines between).
201
+ # @return [Boolean] true if lines are sequential; otherwise false.
186
202
  def lines_are_sequential?(first, second)
187
203
  result = false
188
204
  [:added, :removed].each do |side|
@@ -195,14 +211,14 @@ module GitCommitNotifier
195
211
 
196
212
  def add_changes_to_result
197
213
  return if @current_file_name.nil?
198
-
214
+
199
215
  @lines_added = 0
200
216
  @diff_result << operation_description
201
217
  if !@diff_lines.empty? && !@too_many_files
202
218
  @diff_result << '<table>'
203
219
  removals = []
204
220
  additions = []
205
-
221
+
206
222
  lines = if lines_per_diff.nil?
207
223
  line_budget = nil
208
224
  @diff_lines
@@ -210,7 +226,7 @@ module GitCommitNotifier
210
226
  line_budget = lines_per_diff - @lines_added
211
227
  @diff_lines.slice(0, line_budget)
212
228
  end
213
-
229
+
214
230
  lines.each_with_index do |line, index|
215
231
  removals << line if line[:op] == :removal
216
232
  additions << line if line[:op] == :addition
@@ -230,7 +246,7 @@ module GitCommitNotifier
230
246
  end
231
247
  @lines_added += 1
232
248
  end
233
-
249
+
234
250
  add_skip_notification if !line_budget.nil? && line_budget < @diff_lines.size
235
251
 
236
252
  @diff_result << '</table>'
@@ -336,7 +352,7 @@ module GitCommitNotifier
336
352
  def extract_commit_info_from_git_show_output(content)
337
353
  result = { :message => [], :commit => '', :author => '', :date => '', :email => '',
338
354
  :committer => '', :commit_date => '', :committer_email => ''}
339
-
355
+
340
356
  message = []
341
357
  content.split("\n").each do |line|
342
358
  if line =~ /^diff/ # end of commit info
@@ -357,7 +373,7 @@ module GitCommitNotifier
357
373
  message << line.strip
358
374
  end
359
375
  end
360
-
376
+
361
377
  # Strip blank lines off top and bottom of message
362
378
  while !message.empty? && message.first.empty?
363
379
  message.shift
@@ -366,7 +382,7 @@ module GitCommitNotifier
366
382
  message.pop
367
383
  end
368
384
  result[:message] = message
369
-
385
+
370
386
  result
371
387
  end
372
388
 
@@ -404,7 +420,7 @@ module GitCommitNotifier
404
420
  def merge_commit?(commit_info)
405
421
  ! commit_info[:merge].nil?
406
422
  end
407
-
423
+
408
424
  def truncate_long_lines(text)
409
425
  StringIO.open("", "w") do |output|
410
426
  # Match encoding of output string to that of input string
@@ -444,29 +460,29 @@ module GitCommitNotifier
444
460
  output.string
445
461
  end
446
462
  end
447
-
463
+
464
+ # Commit to link mapping.
465
+ COMMIT_LINK_MAP = {
466
+ :gitweb => lambda { |config, commit| "<a href='#{config['gitweb']['path']}?p=#{config['gitweb']['project'] || "#{Git.repo_name}.git"};a=commitdiff;h=#{commit}'>#{commit}</a>" },
467
+ :gitorious => lambda { |config, commit| "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/commit/#{commit}'>#{commit}</a>" },
468
+ :trac => lambda { |config, commit| "<a href='#{config['trac']['path']}/#{commit}'>#{commit}</a>" },
469
+ :cgit => lambda { |config, commit| "<a href='#{config['cgit']['path']}/#{config['cgit']['project']}/commit/?id=#{commit}'>#{commit}</a>" },
470
+ :gitlabhq => lambda { |config, commit| "<a href='#{config['gitlabhq']['path']}/#{Git.repo_name.gsub(".", "_")}/commits/#{commit}'>#{commit}</a>" },
471
+ :redmine => lambda { |config, commit| "<a href='#{config['redmine']['path']}/projects/#{config['redmine']['project'] || Git.repo_name}/repository/revisions/#{commit}'>#{commit}</a>" },
472
+ :default => lambda { |config, commit| commit.to_s }
473
+ }.freeze
474
+
475
+ # Gets HTML markup for specified commit.
476
+ # @param [String] commit Unique identifier of commit.
477
+ # @return [String] HTML markup for specified commit.
478
+ # @see COMMIT_LINK_MAP
448
479
  def markup_commit_for_html(commit)
449
- commit = if config["link_files"]
450
- if config["link_files"] == "gitweb" && config["gitweb"]
451
- "<a href='#{config['gitweb']['path']}?p=#{Git.repo_name}.git;a=commitdiff;h=#{commit}'>#{commit}</a>"
452
- elsif config["link_files"] == "gitorious" && config["gitorious"]
453
- "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/commit/#{commit}'>#{commit}</a>"
454
- elsif config["link_files"] == "trac" && config["trac"]
455
- "<a href='#{config['trac']['path']}/#{commit}'>#{commit}</a>"
456
- elsif config["link_files"] == "cgit" && config["cgit"]
457
- "<a href='#{config['cgit']['path']}/#{config['cgit']['project']}/commit/?id=#{commit}'>#{commit}</a>"
458
- elsif config["link_files"] == "gitlabhq" && config["gitlabhq"]
459
- "<a href='#{config['gitlabhq']['path']}/#{Git.repo_name.gsub(".", "_")}/commits/#{commit}'>#{commit}</a>"
460
- elsif config["link_files"] == "redmine" && config["redmine"]
461
- "<a href='#{config['redmine']['path']}/projects/#{config['redmine']['project'] || Git.repo_name}/repository/revisions/#{commit}'>#{commit}</a>"
462
- else
463
- "#{commit}"
464
- end
465
- else
466
- "#{commit}"
467
- end
480
+ mode = (config["link_files"] || "default").to_sym
481
+ mode = :default unless config.has_key?(mode)
482
+ mode = :default unless COMMIT_LINK_MAP.has_key?(mode)
483
+ COMMIT_LINK_MAP[mode].call(config, commit)
468
484
  end
469
-
485
+
470
486
  def diff_for_commit(commit)
471
487
  @current_commit = commit
472
488
  raw_diff = truncate_long_lines(Git.show(commit, :ignore_whitespaces => ignore_whitespaces?))
@@ -489,19 +505,19 @@ module GitCommitNotifier
489
505
  title = "<dl class=\"title\">"
490
506
  title += "<dt>Commit</dt><dd>#{markup_commit_for_html(commit_info[:commit])}</dd>\n"
491
507
  title += "<dt>Branch</dt><dd>#{CGI.escapeHTML(branch_name)}</dd>\n" if branch_name
492
-
508
+
493
509
  title += "<dt>Author</dt><dd>#{CGI.escapeHTML(commit_info[:author])} &lt;#{commit_info[:email]}&gt;</dd>\n"
494
-
510
+
495
511
  # Show separate committer name/email only if it differs from author
496
512
  if commit_info[:author] != commit_info[:committer] || commit_info[:email] != commit_info[:commit_email]
497
513
  title += "<dt>Committer</dt><dd>#{CGI.escapeHTML(commit_info[:committer])} &lt;#{commit_info[:commit_email]}&gt;</dd>\n"
498
514
  end
499
515
 
500
516
  title += "<dt>Date</dt><dd>#{CGI.escapeHTML commit_info[:date]}</dd>\n"
501
-
517
+
502
518
  multi_line_message = commit_info[:message].count > 1
503
519
  title += "<dt>Message</dt><dd class='#{multi_line_message ? "multi-line" : ""}'>#{message_array_as_html(commit_info[:message])}</dd>\n"
504
-
520
+
505
521
  title += "</dl>"
506
522
 
507
523
  text = "#{raw_diff}"
@@ -521,38 +537,38 @@ module GitCommitNotifier
521
537
  end
522
538
 
523
539
  def diff_for_lightweight_tag(tag, rev, change_type)
524
-
540
+
525
541
  if change_type == :delete
526
542
  message = "Remove Lightweight Tag #{tag}"
527
-
543
+
528
544
  html = "<dl class='title'>"
529
545
  html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (removed)</dd>\n"
530
546
  html += "<dt>Type</dt><dd>lightweight</dd>\n"
531
547
  html += "<dt>Commit</dt><dd>#{markup_commit_for_html(rev)}</dd>\n"
532
548
  html += "</dl>"
533
-
549
+
534
550
  text = "Remove Tag: #{tag}\n"
535
551
  text += "Type: lightweight\n"
536
552
  text += "Commit: #{rev}\n"
537
553
  else
538
554
  message = "#{change_type == :create ? "Add" : "Update"} Lightweight Tag #{tag}"
539
-
555
+
540
556
  html = "<dl class='title'>"
541
557
  html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (#{change_type == :create ? "added" : "updated"})</dd>\n"
542
558
  html += "<dt>Type</dt><dd>lightweight</dd>\n"
543
559
  html += "<dt>Commit</dt><dd>#{markup_commit_for_html(rev)}</dd>\n"
544
560
  html += "</dl>"
545
-
561
+
546
562
  text = "Tag: #{tag} (#{change_type == :create ? "added" : "updated"})\n"
547
563
  text += "Type: lightweight\n"
548
564
  text += "Commit: #{rev}\n"
549
565
  end
550
-
566
+
551
567
  commit_info = {
552
568
  :commit => rev,
553
569
  :message => message
554
570
  }
555
-
571
+
556
572
  @result << {
557
573
  :commit_info => commit_info,
558
574
  :html_content => html,
@@ -561,26 +577,26 @@ module GitCommitNotifier
561
577
  end
562
578
 
563
579
  def diff_for_annotated_tag(tag, rev, change_type)
564
-
580
+
565
581
  commit_info = {
566
582
  :commit => rev
567
583
  }
568
-
584
+
569
585
  if change_type == :delete
570
586
  message = "Remove Annotated Tag #{tag}"
571
-
587
+
572
588
  html = "<dl class='title'>"
573
589
  html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (removed)</dd>\n"
574
590
  html += "<dt>Type</dt><dd>annotated</dd>\n"
575
591
  html += "</dl>"
576
-
592
+
577
593
  text = message
578
594
  commit_info[:message] = message
579
595
  else
580
596
  tag_info = Git.tag_info(ref_name)
581
597
 
582
598
  message = tag_info[:subject] || "#{change_type == :create ? "Add" : "Update"} Annotated Tag #{tag}"
583
-
599
+
584
600
  html = "<dl class='title'>"
585
601
  html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (#{change_type == :create ? "added" : "updated"})</dd>\n"
586
602
  html += "<dt>Type</dt><dd>annotated</dd>\n"
@@ -591,17 +607,17 @@ module GitCommitNotifier
591
607
  multi_line_message = message_array.count > 1
592
608
  html += "<dt>Message</dt><dd class='#{multi_line_message ? "multi-line" : ""}'>#{message_array_as_html(message_array)}</dd>\n"
593
609
  html += "</dl>"
594
-
610
+
595
611
  text = "Tag:</strong> #{tag} (#{change_type == :create ? "added" : "updated"})\n"
596
612
  text += "Type: annotated\n"
597
613
  text += "Commit: #{tag_info[:tagobject]}\n"
598
614
  text += "Tagger: tag_info[:taggername] tag_info[:taggeremail]\n"
599
615
  text += "Message: #{tag_info[:contents]}\n"
600
-
616
+
601
617
  commit_info[:message] = message
602
618
  commit_info[:author], commit_info[:email] = author_name_and_email("#{tag_info[:taggername]} #{tag_info[:taggeremail]}")
603
619
  end
604
-
620
+
605
621
  @result << {
606
622
  :commit_info => commit_info,
607
623
  :html_content => html,
@@ -609,7 +625,7 @@ module GitCommitNotifier
609
625
  }
610
626
  end
611
627
 
612
- def diff_for_branch(branch, rev, change_type)
628
+ def diff_for_branch(branch, rev, change_type)
613
629
  commits = case change_type
614
630
  when :delete
615
631
  puts "ignoring branch delete"
@@ -617,11 +633,11 @@ module GitCommitNotifier
617
633
  when :create, :update
618
634
  # Note that "unique_commits_per_branch" really means "consider commits
619
635
  # on this branch without regard to whether they occur on other branches"
620
- # The flag unique_to_current_branch passed to new_commits means the
636
+ # The flag unique_to_current_branch passed to new_commits means the
621
637
  # opposite: "consider only commits that are unique to this branch"
622
638
  Git.new_commits(oldrev, newrev, ref_name, !unique_commits_per_branch?)
623
639
  end
624
-
640
+
625
641
  # Add each diff to @result
626
642
  commits.each do |commit|
627
643
  commit_result = diff_for_commit(commit)
@@ -636,7 +652,7 @@ module GitCommitNotifier
636
652
 
637
653
  def diff_between_revisions(rev1, rev2, repo, ref_name)
638
654
  clear_result
639
-
655
+
640
656
  # Cleanup revs
641
657
  @oldrev = Git.rev_parse(rev1)
642
658
  @newrev = Git.rev_parse(rev2)
@@ -650,7 +666,7 @@ module GitCommitNotifier
650
666
  else
651
667
  :update
652
668
  end
653
-
669
+
654
670
  # Establish type of the revs
655
671
  @oldrev_type = Git.rev_type(@oldrev)
656
672
  @newrev_type = Git.rev_type(@newrev)
@@ -661,7 +677,7 @@ module GitCommitNotifier
661
677
  @rev_type = @newrev_type
662
678
  @rev = @newrev
663
679
  end
664
-
680
+
665
681
  # Determine what to do based on the ref_name and the rev_type
666
682
  case "#{@ref_name},#{@rev_type}"
667
683
  when %r!^refs/tags/(.+),commit$!
@@ -680,7 +696,7 @@ module GitCommitNotifier
680
696
  # Something we don't understand
681
697
  puts "Unknown change type #{ref_name},#{@rev_type}"
682
698
  end
683
-
699
+
684
700
  # If a block was given, pass it the results, in turn
685
701
  @result.each { |result| yield result } if block_given?
686
702
  end
@@ -698,7 +714,7 @@ module GitCommitNotifier
698
714
  end
699
715
 
700
716
  def do_message_integration(message)
701
- return message unless config['message_integration'].respond_to?(:each_pair)
717
+ return message unless config['message_integration'].respond_to?(:each_pair)
702
718
  config['message_integration'].each_pair do |pm, url|
703
719
  pm_def = DiffToHtml::INTEGRATION_MAP[pm.to_sym] or next
704
720
  search_for = pm_def[:search_for]
@@ -711,7 +727,7 @@ module GitCommitNotifier
711
727
  end
712
728
 
713
729
  def do_message_map(message)
714
- return message unless config['message_map'].respond_to?(:each_pair)
730
+ return message unless config['message_map'].respond_to?(:each_pair)
715
731
  config['message_map'].each_pair do |search_for, replace_with|
716
732
  message_replace!(message, Regexp.new(search_for), replace_with)
717
733
  end
@@ -723,3 +739,4 @@ module GitCommitNotifier
723
739
  end
724
740
  end
725
741
  end
742
+