git-commit-notifier 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +32 -0
- data/VERSION +1 -1
- data/config/git-notifier-config.yml.sample +26 -2
- data/git-commit-notifier.gemspec +7 -4
- data/lib/commit_hook.rb +39 -5
- data/lib/diff_to_html.rb +45 -5
- data/lib/emailer.rb +33 -4
- data/test/fixtures/existing_file_one_line.txt +9 -0
- data/test/fixtures/git-notifier-group-email-by-push.yml +19 -0
- data/test/fixtures/new_file_one_line.txt +6 -0
- data/test/unit/test_commit_hook.rb +18 -7
- data/test/unit/test_diff_to_html.rb +45 -1
- metadata +21 -5
data/README.textile
CHANGED
@@ -44,6 +44,29 @@ git-commit-notifier path_to_config.yml
|
|
44
44
|
|
45
45
|
An example for the config file can be found in <a href="http://github.com/bitboxer/git-commit-notifier/blob/master/config/git-notifier-config.yml.sample">config/git-notifier-config.yml.sample</a>.
|
46
46
|
|
47
|
+
h2. Integration with Redmine, Bugzilla, MediaWiki
|
48
|
+
|
49
|
+
Git-commit-notifier supports easy integration with Redmine, Bugzilla and MediaWiki. All you need is to uncomment the according line in the configuration and change the links to your software installations instead of example ones (no trailing slash please).
|
50
|
+
|
51
|
+
* "BUG 123" sentence in commit message will be replaced with link to bug in Bugzilla.
|
52
|
+
* "refs #123" and "fixes #123" sentences in commit message will be replaced with link to issue in Redmine.
|
53
|
+
* "[[SomePage]]" sentence in commit message will be replaced with link to page in MediaWiki.
|
54
|
+
|
55
|
+
h2. Integration of links to other websites
|
56
|
+
|
57
|
+
If you need integration with other websites not supported by git-commit-notifier you can use the message_map property. For that you need to know basics of regular expressions syntax.
|
58
|
+
|
59
|
+
Each key of message_map is a case sensitive Regexp pattern, and its value is the replacement string.
|
60
|
+
Every matched group (that defined by round brackets in regular expression) will be automatically substituted instead of \1-\9 backreferences in replacement string where number after backslash informs which group should be substituted instead of the backreference. The first matched group is known as \1.
|
61
|
+
|
62
|
+
For example, when we need to expand "follow 23" to http://example.com/answer/23, simply type this:
|
63
|
+
|
64
|
+
'\bfollow\s+(\d+)': 'http://example.com/answer/\1'
|
65
|
+
|
66
|
+
Key and value are enclosed into single quotes. \b means that "follow" must not be preceded by other word chars, so "befollow" will not match but "be follow" will match. After "follow" we expect one or more spaces followed by group of one or more digits. The \1 in the result url will be replaced with the matched group.
|
67
|
+
|
68
|
+
More examples can be found in the config file.
|
69
|
+
|
47
70
|
h2. Note on Patches/Pull Requests
|
48
71
|
|
49
72
|
* Fork the project.
|
@@ -54,6 +77,15 @@ h2. Note on Patches/Pull Requests
|
|
54
77
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
55
78
|
* Send me a pull request. Bonus points for topic branches.
|
56
79
|
|
80
|
+
h2. Troubleshooting
|
81
|
+
|
82
|
+
h3. Permission denied - /var/git/repo/previously.txt (Errno::EACCES)
|
83
|
+
|
84
|
+
The file __previously.txt__ is created at the first commit. If you moved the file to the server, you have to check the rights to that file and fix them if needed.
|
85
|
+
|
86
|
+
<pre>sudo touch /var/git/repo/previously.txt
|
87
|
+
sudo chmod a+x /var/git/repo/previously.txt</pre>
|
88
|
+
|
57
89
|
h2. License
|
58
90
|
|
59
91
|
MIT License, see the file LICENSE.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
@@ -7,12 +7,18 @@ ignore_merge: false
|
|
7
7
|
# Optional parameter for the subject-line of the mail
|
8
8
|
# emailprefix: GIT
|
9
9
|
|
10
|
-
# Decorate files with link to a webview. Possible values: none or
|
10
|
+
# Decorate files with link to a webview. Possible values: none, gitweb or gitorious
|
11
11
|
link_files: none
|
12
12
|
|
13
|
+
# Limit lines per diff
|
14
|
+
# lines_per_diff: 300
|
15
|
+
|
13
16
|
# select the delivery method: smtp or sendmail
|
14
17
|
delivery_method: sendmail
|
15
18
|
|
19
|
+
# Optionally group email by push: don't send an email for each commit when true.
|
20
|
+
# group_email_by_push: false
|
21
|
+
|
16
22
|
# settings for the smtp server
|
17
23
|
smtp_server:
|
18
24
|
address: localhost
|
@@ -28,8 +34,26 @@ sendmail_options:
|
|
28
34
|
location: /usr/sbin/sendmail
|
29
35
|
arguments: -i -t
|
30
36
|
|
37
|
+
# commit message URL map
|
38
|
+
message_map:
|
39
|
+
# '\brefs\s*\#(\d+)': 'http://example.com/redmine/issues/show/\1'
|
40
|
+
|
41
|
+
# Uncomment if you want to create links in your commit text
|
42
|
+
message_integration:
|
43
|
+
# mediawiki: http://example.com/wiki # will rework [[text]] to MediaWiki pages
|
44
|
+
# redmine: http://redmine.example.com # will rework refs #123 to Redmine issues
|
45
|
+
# bugzilla: http://bz.example.com # will rework BUG 123 to Bugzilla bugs
|
46
|
+
|
31
47
|
# If link_files is set to "gitweb", you need to configure the path to your gitweb
|
32
48
|
# instance and the project name.
|
33
49
|
gitweb:
|
34
50
|
path: http://developerserver/path_to_gitweb
|
35
|
-
project: test.git
|
51
|
+
project: test.git
|
52
|
+
|
53
|
+
# If link_files is set to "gitorious", you need to configure the path to your gitorious
|
54
|
+
# instance, the project name and the repository name.
|
55
|
+
gitorious:
|
56
|
+
path: http://example.com/path_to_gitorious
|
57
|
+
project: backend
|
58
|
+
repository: sql-scripts
|
59
|
+
|
data/git-commit-notifier.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{git-commit-notifier}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8.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-
|
12
|
+
s.date = %q{2010-08-06}
|
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@wannawork.de}
|
@@ -35,6 +35,8 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/result_processor.rb",
|
36
36
|
"template/email.html.erb",
|
37
37
|
"template/styles.css",
|
38
|
+
"test/fixtures/existing_file_one_line.txt",
|
39
|
+
"test/fixtures/git-notifier-group-email-by-push.yml",
|
38
40
|
"test/fixtures/git-notifier-ignore-merge.yml",
|
39
41
|
"test/fixtures/git-notifier-with-merge.yml",
|
40
42
|
"test/fixtures/git_log",
|
@@ -43,6 +45,7 @@ Gem::Specification.new do |s|
|
|
43
45
|
"test/fixtures/git_show_a4629e707d80a5769f7a71ca6ed9471015e14dc9",
|
44
46
|
"test/fixtures/git_show_dce6ade4cdc2833b53bd600ef10f9bce83c7102d",
|
45
47
|
"test/fixtures/git_show_e28ad77bba0574241e6eb64dfd0c1291b221effe",
|
48
|
+
"test/fixtures/new_file_one_line.txt",
|
46
49
|
"test/test_helper.rb",
|
47
50
|
"test/unit/test_commit_hook.rb",
|
48
51
|
"test/unit/test_diff_to_html.rb",
|
@@ -51,7 +54,7 @@ Gem::Specification.new do |s|
|
|
51
54
|
s.homepage = %q{http://github.com/bodo/git-commit-notifier}
|
52
55
|
s.rdoc_options = ["--charset=UTF-8"]
|
53
56
|
s.require_paths = ["lib"]
|
54
|
-
s.rubygems_version = %q{1.3.
|
57
|
+
s.rubygems_version = %q{1.3.7}
|
55
58
|
s.summary = %q{Sends git commit messages with diffs}
|
56
59
|
s.test_files = [
|
57
60
|
"test/test_helper.rb",
|
@@ -64,7 +67,7 @@ Gem::Specification.new do |s|
|
|
64
67
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
68
|
s.specification_version = 3
|
66
69
|
|
67
|
-
if Gem::Version.new(Gem::
|
70
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
71
|
s.add_runtime_dependency(%q<diff-lcs>, [">= 0"])
|
69
72
|
s.add_runtime_dependency(%q<mocha>, [">= 0"])
|
70
73
|
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
|
data/lib/commit_hook.rb
CHANGED
@@ -47,12 +47,46 @@ class CommitHook
|
|
47
47
|
!result[:commit_info][:merge].nil?
|
48
48
|
}
|
49
49
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
|
51
|
+
if (@config["group_email_by_push"])
|
52
|
+
text, html = [], []
|
53
|
+
diffresult.each_with_index do |result, i|
|
54
|
+
text << result[:text_content]
|
55
|
+
html << result[:html_content]
|
56
|
+
end
|
57
|
+
result = diffresult.first
|
58
|
+
emailer = Emailer.new(
|
59
|
+
@config,
|
60
|
+
project_path,
|
61
|
+
recipient,
|
62
|
+
result[:commit_info][:email],
|
63
|
+
result[:commit_info][:author],
|
64
|
+
"[#{prefix}#{branch_name}] #{diffresult.size > 1 ? "#{diffresult.size} commits: " : ''}#{result[:commit_info][:message]}",
|
65
|
+
text.join("------------------------------------------\n\n"),
|
66
|
+
html.join("<hr /><br />"),
|
67
|
+
rev1,
|
68
|
+
rev2,
|
69
|
+
ref_name
|
70
|
+
)
|
55
71
|
emailer.send
|
72
|
+
else
|
73
|
+
diffresult.reverse.each_with_index do |result, i|
|
74
|
+
nr = number(diffresult.size, i)
|
75
|
+
emailer = Emailer.new(
|
76
|
+
@config,
|
77
|
+
project_path,
|
78
|
+
recipient,
|
79
|
+
result[:commit_info][:email],
|
80
|
+
result[:commit_info][:author],
|
81
|
+
"[#{prefix}#{branch_name}]#{nr} #{result[:commit_info][:message]}",
|
82
|
+
result[:text_content],
|
83
|
+
result[:html_content],
|
84
|
+
rev1,
|
85
|
+
rev2,
|
86
|
+
ref_name
|
87
|
+
)
|
88
|
+
emailer.send
|
89
|
+
end
|
56
90
|
end
|
57
91
|
end
|
58
92
|
|
data/lib/diff_to_html.rb
CHANGED
@@ -7,19 +7,24 @@ def escape_content(s)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class DiffToHtml
|
10
|
+
INTEGRATION_MAP = {
|
11
|
+
:mediawiki => { :search_for => /\[\[([^\[\]]+)\]\]/, :replace_with => '#{url}/\1' },
|
12
|
+
:redmine => { :search_for => /\b(?:refs|fixes)\s*\#(\d+)/i, :replace_with => '#{url}/issues/show/\1' },
|
13
|
+
:bugzilla => { :search_for => /\bBUG\s*(\d+)/i, :replace_with => '#{url}/show_bug.cgi?id=\1' }
|
14
|
+
}.freeze
|
15
|
+
|
10
16
|
attr_accessor :file_prefix, :current_file_name
|
11
17
|
attr_reader :result
|
12
18
|
|
13
19
|
def initialize(previous_dir = nil, config = nil)
|
14
20
|
@previous_dir = previous_dir
|
15
21
|
@config = config || {}
|
22
|
+
@lines_added = 0
|
16
23
|
end
|
17
24
|
|
18
25
|
def range_info(range)
|
19
|
-
range.match(/^@@ \-(\
|
20
|
-
|
21
|
-
right_ln = Integer($2)
|
22
|
-
return left_ln, right_ln
|
26
|
+
matches = range.match(/^@@ \-(\S+) \+(\S+)/)
|
27
|
+
return matches[1..2].map { |m| m.split(',')[0].to_i }
|
23
28
|
end
|
24
29
|
|
25
30
|
def line_class(line)
|
@@ -40,6 +45,16 @@ class DiffToHtml
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def add_line_to_result(line, escape)
|
48
|
+
@lines_added += 1
|
49
|
+
lines_per_diff = @config['lines_per_diff']
|
50
|
+
if lines_per_diff
|
51
|
+
if @lines_added == lines_per_diff
|
52
|
+
@diff_result << '<tr><td colspan="3">Diff too large and stripped…</td></tr>'
|
53
|
+
end
|
54
|
+
if @lines_added >= lines_per_diff
|
55
|
+
return
|
56
|
+
end
|
57
|
+
end
|
43
58
|
klass = line_class(line)
|
44
59
|
content = escape ? escape_content(line[:content]) : line[:content]
|
45
60
|
padding = ' ' if klass != ''
|
@@ -113,6 +128,8 @@ class DiffToHtml
|
|
113
128
|
|
114
129
|
if (@config["link_files"] && @config["link_files"] == "gitweb" && @config["gitweb"])
|
115
130
|
file_name = "<a href='#{@config['gitweb']['path']}?p=#{@config['gitweb']['project']};f=#{file_name};hb=HEAD'>#{file_name}</a>"
|
131
|
+
elsif (@config["link_files"] && @config["link_files"] == "gitorious" && @config["gitorious"])
|
132
|
+
file_name = "<a href='#{@config['gitorious']['path']}/#{@config['gitorious']['project']}/#{@config['gitorious']['repository']}/blobs/HEAD/#{file_name}'>#{file_name}</a>"
|
116
133
|
end
|
117
134
|
|
118
135
|
header = "#{op} #{binary}file #{file_name}"
|
@@ -241,7 +258,7 @@ class DiffToHtml
|
|
241
258
|
end
|
242
259
|
|
243
260
|
def message_array_as_html(message)
|
244
|
-
message.collect { |m| CGI.escapeHTML(m)}.join("<br />")
|
261
|
+
message_map(message.collect { |m| CGI.escapeHTML(m)}.join("<br />"))
|
245
262
|
end
|
246
263
|
|
247
264
|
def author_name_and_email(info)
|
@@ -298,6 +315,8 @@ class DiffToHtml
|
|
298
315
|
|
299
316
|
if (@config["link_files"] && @config["link_files"] == "gitweb" && @config["gitweb"])
|
300
317
|
title += "<a href='#{@config['gitweb']['path']}?p=#{@config['gitweb']['project']};a=commitdiff;h=#{commit_info[:commit]}'>#{commit_info[:commit]}</a>"
|
318
|
+
elsif (@config["link_files"] && @config["link_files"] == "gitorious" && @config["gitorious"])
|
319
|
+
title += "<a href='#{@config['gitorious']['path']}/#{@config['gitorious']['project']}/#{@config['gitorious']['repository']}/commit/#{commit_info[:commit]}'>#{commit_info[:commit]}</a>"
|
301
320
|
else
|
302
321
|
title += " #{commit_info[:commit]}"
|
303
322
|
end
|
@@ -317,6 +336,27 @@ class DiffToHtml
|
|
317
336
|
@result << {:commit_info => commit_info, :html_content => html, :text_content => text }
|
318
337
|
end
|
319
338
|
end
|
339
|
+
|
340
|
+
def message_replace!(message, search_for, replace_with)
|
341
|
+
full_replace_with = "<a href=\"#{replace_with}\">\\0</a>"
|
342
|
+
message.gsub!(Regexp.new(search_for), full_replace_with)
|
343
|
+
end
|
344
|
+
|
345
|
+
def message_map(message)
|
346
|
+
if @config.include?('message_integration')
|
347
|
+
@config['message_integration'].each_pair do |pm, url|
|
348
|
+
pm_def = DiffToHtml::INTEGRATION_MAP[pm.to_sym] or next
|
349
|
+
replace_with = pm_def[:replace_with].gsub('#{url}', url)
|
350
|
+
message_replace!(message, pm_def[:search_for], replace_with)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
if @config.include?('message_map')
|
354
|
+
@config['message_map'].each_pair do |search_for, replace_with|
|
355
|
+
message_replace!(message, Regexp.new(search_for), replace_with)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
message
|
359
|
+
end
|
320
360
|
end
|
321
361
|
|
322
362
|
class DiffCallback
|
data/lib/emailer.rb
CHANGED
@@ -63,13 +63,13 @@ class Emailer
|
|
63
63
|
f.flush
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def send
|
68
|
-
from = @from_alias.empty? ? @from_address : "#{@from_alias} <#{@from_address}>"
|
68
|
+
from = quote_if_necessary(@from_alias.empty? ? @from_address : "#{@from_alias} <#{@from_address}>", 'utf-8')
|
69
69
|
content = ["From: #{from}",
|
70
70
|
"Reply-To: #{from}",
|
71
|
-
"To: #{@recipient}",
|
72
|
-
"Subject: #{@subject}",
|
71
|
+
"To: #{quote_if_necessary(@recipient, 'utf-8')}",
|
72
|
+
"Subject: #{quote_if_necessary(@subject, 'utf-8')}",
|
73
73
|
"X-Git-Refname: #{@ref_name}",
|
74
74
|
"X-Git-Oldrev: #{@old_rev}",
|
75
75
|
"X-Git-Newrev: #{@new_rev}",
|
@@ -99,4 +99,33 @@ class Emailer
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
# Convert the given text into quoted printable format, with an instruction
|
103
|
+
# that the text be eventually interpreted in the given charset.
|
104
|
+
def quoted_printable(text, charset)
|
105
|
+
text = text.gsub( /[^a-z ]/i ) { quoted_printable_encode($&) }.
|
106
|
+
gsub( / /, "_" )
|
107
|
+
"=?#{charset}?Q?#{text}?="
|
108
|
+
end
|
109
|
+
|
110
|
+
# Convert the given character to quoted printable format, taking into
|
111
|
+
# account multi-byte characters (if executing with $KCODE="u", for instance)
|
112
|
+
def quoted_printable_encode(character)
|
113
|
+
result = ""
|
114
|
+
character.each_byte { |b| result << "=%02X" % b }
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
# A quick-and-dirty regexp for determining whether a string contains any
|
119
|
+
# characters that need escaping.
|
120
|
+
CHARS_NEEDING_QUOTING = /[\000-\011\013\014\016-\037\177-\377]/
|
121
|
+
|
122
|
+
# Quote the given text if it contains any "illegal" characters
|
123
|
+
def quote_if_necessary(text, charset)
|
124
|
+
text = text.dup.force_encoding(Encoding::ASCII_8BIT) if text.respond_to?(:force_encoding)
|
125
|
+
|
126
|
+
(text =~ CHARS_NEEDING_QUOTING) ?
|
127
|
+
quoted_printable(text, charset) :
|
128
|
+
text
|
129
|
+
end
|
102
130
|
end
|
131
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
delivery_method: sendmail # smtp or sendmail
|
2
|
+
ignore_merge: false # set to true if you want to ignore empty merge messages
|
3
|
+
|
4
|
+
group_email_by_push: true
|
5
|
+
|
6
|
+
smtp_server:
|
7
|
+
address: localhost
|
8
|
+
port: 25
|
9
|
+
domain: localhost
|
10
|
+
user_name: user@localhost
|
11
|
+
password: password
|
12
|
+
authentication: plain
|
13
|
+
enable_tls: false
|
14
|
+
|
15
|
+
sendmail_options:
|
16
|
+
location: /usr/sbin/sendmail
|
17
|
+
arguments:
|
18
|
+
|
19
|
+
|
@@ -8,25 +8,36 @@ require File.dirname(__FILE__) + '/../../lib/git'
|
|
8
8
|
class CommitHookTest < Test::Unit::TestCase
|
9
9
|
|
10
10
|
def test_hook_ignore_merge
|
11
|
-
|
11
|
+
# 4 commits, one email for each of them, without merge
|
12
|
+
run_with_config('test/fixtures/git-notifier-ignore-merge.yml', 4)
|
12
13
|
end
|
13
14
|
|
14
15
|
def test_hook_with_merge
|
15
|
-
|
16
|
+
# 5 commits, one email for each of them, with merge mail
|
17
|
+
run_with_config('test/fixtures/git-notifier-with-merge.yml', 5)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_hook_group_email_by_push
|
21
|
+
# 1 commit for the push, all commits in the one message
|
22
|
+
run_with_config('test/fixtures/git-notifier-group-email-by-push.yml', 1)
|
16
23
|
end
|
17
24
|
|
18
25
|
def run_with_config(config, times)
|
26
|
+
expect_repository_access
|
27
|
+
|
28
|
+
emailer = mock('Emailer')
|
29
|
+
Emailer.expects(:new).times(times).returns(emailer)
|
30
|
+
emailer.expects(:send).times(times)
|
31
|
+
CommitHook.run config, REVISIONS.first, REVISIONS.last, 'refs/heads/master'
|
32
|
+
end
|
33
|
+
|
34
|
+
def expect_repository_access
|
19
35
|
path = File.dirname(__FILE__) + '/../fixtures/'
|
20
36
|
Git.expects(:log).with(REVISIONS.first, REVISIONS.last).returns(read_file(path + 'git_log'))
|
21
37
|
Git.expects(:mailing_list_address).returns('recipient@test.com')
|
22
38
|
REVISIONS.each do |rev|
|
23
39
|
Git.expects(:show).with(rev).returns(read_file(path + "git_show_#{rev}"))
|
24
40
|
end
|
25
|
-
emailer = mock('Emailer')
|
26
|
-
Emailer.expects(:new).times(times).returns(emailer) # 4 commit, one email for each of them
|
27
|
-
emailer.expects(:send).times(times)
|
28
|
-
CommitHook.run config, REVISIONS.first, REVISIONS.last, 'refs/heads/master'
|
29
41
|
end
|
30
42
|
|
31
|
-
|
32
43
|
end
|
@@ -94,7 +94,7 @@ class DiffToHtmlTest < Test::Unit::TestCase
|
|
94
94
|
'key',',',' ','scope'], tokens
|
95
95
|
end
|
96
96
|
|
97
|
-
def
|
97
|
+
def test_gitweb_operation_description
|
98
98
|
diff = DiffToHtml.new
|
99
99
|
diff.current_file_name = "file/to/test.yml"
|
100
100
|
assert_equal "<h2>Changed file file/to/test.yml</h2>\n", diff.operation_description
|
@@ -110,7 +110,51 @@ class DiffToHtmlTest < Test::Unit::TestCase
|
|
110
110
|
diff = DiffToHtml.new(nil, config)
|
111
111
|
diff.current_file_name = "file/to/test.yml"
|
112
112
|
assert_equal "<h2>Changed file <a href='http://developerserver/path_to_gitweb?p=test.git;f=file/to/test.yml;hb=HEAD'>file/to/test.yml</a></h2>\n", diff.operation_description
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_gitorious_operation_description
|
116
|
+
diff = DiffToHtml.new
|
117
|
+
diff.current_file_name = "file/to/test.yml"
|
118
|
+
assert_equal "<h2>Changed file file/to/test.yml</h2>\n", diff.operation_description
|
119
|
+
|
120
|
+
config = {
|
121
|
+
"link_files" => "gitorious",
|
122
|
+
"gitorious" => {
|
123
|
+
"path" => "http://example.com/gitorious",
|
124
|
+
"project" => "tests",
|
125
|
+
"repository" => "test",
|
126
|
+
}
|
127
|
+
}
|
113
128
|
|
129
|
+
diff = DiffToHtml.new(nil, config)
|
130
|
+
diff.current_file_name = "file/to/test.yml"
|
131
|
+
assert_equal "<h2>Changed file <a href='http://example.com/gitorious/tests/test/blobs/HEAD/file/to/test.yml'>file/to/test.yml</a></h2>\n", diff.operation_description
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_should_correctly_set_line_numbers_on_single_line_add_to_new_file
|
135
|
+
diff = DiffToHtml.new
|
136
|
+
diff.expects(:add_line_to_result).with() { |line, escape| line[:added] == 1 }
|
137
|
+
content = IO.read('test/fixtures/new_file_one_line.txt')
|
138
|
+
result = diff.diff_for_revision(content)
|
114
139
|
end
|
115
140
|
|
141
|
+
def test_should_correctly_set_line_numbers_on_single_line_add_to_existing_file
|
142
|
+
diff = DiffToHtml.new
|
143
|
+
diff.expects(:add_line_to_result).at_least_once
|
144
|
+
diff.expects(:add_line_to_result).at_least_once.with() { |line, escape| line[:added] == 5 && line[:removed] == nil }
|
145
|
+
content = IO.read('test/fixtures/existing_file_one_line.txt')
|
146
|
+
result = diff.diff_for_revision(content)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_message_map_should_correctly_rework_message
|
150
|
+
diff = DiffToHtml.new(nil, 'message_map' => {
|
151
|
+
'\brefs\s*\#(\d+)' => 'http://redmine.example.com/issues/show/\1'
|
152
|
+
}, 'message_integration' => {
|
153
|
+
'bugzilla' => 'http://bugzilla.example.com'
|
154
|
+
})
|
155
|
+
assert_equal(
|
156
|
+
'<a href="http://bugzilla.example.com/show_bug.cgi?id=15">BUG 15</a>. Draft design <a href="http://redmine.example.com/issues/show/5654">refs #5654</a>',
|
157
|
+
diff.message_map('BUG 15. Draft design refs #5654')
|
158
|
+
)
|
159
|
+
end
|
116
160
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-commit-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 63
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 0.8.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Bodo Tasche
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-06 00:00:00 +02:00
|
18
19
|
default_executable: git-commit-notifier
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: diff-lcs
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: mocha
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -45,9 +50,11 @@ dependencies:
|
|
45
50
|
name: hpricot
|
46
51
|
prerelease: false
|
47
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
55
|
- - ">="
|
50
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
51
58
|
segments:
|
52
59
|
- 0
|
53
60
|
version: "0"
|
@@ -57,9 +64,11 @@ dependencies:
|
|
57
64
|
name: tamtam
|
58
65
|
prerelease: false
|
59
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
69
|
- - ">="
|
62
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
63
72
|
segments:
|
64
73
|
- 0
|
65
74
|
version: "0"
|
@@ -91,6 +100,8 @@ files:
|
|
91
100
|
- lib/result_processor.rb
|
92
101
|
- template/email.html.erb
|
93
102
|
- template/styles.css
|
103
|
+
- test/fixtures/existing_file_one_line.txt
|
104
|
+
- test/fixtures/git-notifier-group-email-by-push.yml
|
94
105
|
- test/fixtures/git-notifier-ignore-merge.yml
|
95
106
|
- test/fixtures/git-notifier-with-merge.yml
|
96
107
|
- test/fixtures/git_log
|
@@ -99,6 +110,7 @@ files:
|
|
99
110
|
- test/fixtures/git_show_a4629e707d80a5769f7a71ca6ed9471015e14dc9
|
100
111
|
- test/fixtures/git_show_dce6ade4cdc2833b53bd600ef10f9bce83c7102d
|
101
112
|
- test/fixtures/git_show_e28ad77bba0574241e6eb64dfd0c1291b221effe
|
113
|
+
- test/fixtures/new_file_one_line.txt
|
102
114
|
- test/test_helper.rb
|
103
115
|
- test/unit/test_commit_hook.rb
|
104
116
|
- test/unit/test_diff_to_html.rb
|
@@ -113,23 +125,27 @@ rdoc_options:
|
|
113
125
|
require_paths:
|
114
126
|
- lib
|
115
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
116
129
|
requirements:
|
117
130
|
- - ">="
|
118
131
|
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
119
133
|
segments:
|
120
134
|
- 0
|
121
135
|
version: "0"
|
122
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
123
138
|
requirements:
|
124
139
|
- - ">="
|
125
140
|
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
126
142
|
segments:
|
127
143
|
- 0
|
128
144
|
version: "0"
|
129
145
|
requirements: []
|
130
146
|
|
131
147
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.3.
|
148
|
+
rubygems_version: 1.3.7
|
133
149
|
signing_key:
|
134
150
|
specification_version: 3
|
135
151
|
summary: Sends git commit messages with diffs
|