git-commit-notifier 0.5.0 → 0.6.1
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/LICENSE +1 -1
- data/README.textile +0 -6
- data/VERSION +1 -1
- data/config/git-notifier-config.yml.sample +11 -2
- data/git-commit-notifier.gemspec +2 -2
- data/lib/commit_hook.rb +6 -6
- data/lib/diff_to_html.rb +13 -5
- data/lib/emailer.rb +1 -2
- data/test/unit/test_diff_to_html.rb +19 -0
- metadata +4 -4
data/LICENSE
CHANGED
data/README.textile
CHANGED
@@ -33,12 +33,6 @@ h1. Requirements
|
|
33
33
|
|
34
34
|
h1. Installing and Configuring
|
35
35
|
|
36
|
-
Before installing the Git Commit Notification script, make sure the following
|
37
|
-
Git settings are configured correctly.
|
38
|
-
|
39
|
-
* git config hooks.mailinglist (email address of the recipient, probably your mailing list address)
|
40
|
-
* __Optional:__ git config hooks.emailprefix (application name, used in email subject)
|
41
|
-
|
42
36
|
Install the gem:
|
43
37
|
|
44
38
|
<pre>sudo gem install git-commit-notifier</pre>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|
@@ -1,5 +1,12 @@
|
|
1
|
-
delivery_method: sendmail # smtp or sendmail
|
2
1
|
ignore_merge: false # set to true if you want to ignore empty merge messages
|
2
|
+
mailinglist: developers@example.com # recipient for the commit mail
|
3
|
+
|
4
|
+
# Optional parameter for the subject-line of the mail
|
5
|
+
# emailprefix: GIT
|
6
|
+
|
7
|
+
link_files: none # Decorates files with link to a webview. Possible values: none or gitweb
|
8
|
+
|
9
|
+
delivery_method: sendmail # smtp or sendmail
|
3
10
|
|
4
11
|
smtp_server:
|
5
12
|
address: localhost
|
@@ -14,4 +21,6 @@ sendmail_options:
|
|
14
21
|
location: /usr/sbin/sendmail
|
15
22
|
arguments:
|
16
23
|
|
17
|
-
|
24
|
+
gitweb:
|
25
|
+
path: http://developerserver/path_to_gitweb
|
26
|
+
project: test.git
|
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.6.1"
|
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-03-
|
12
|
+
s.date = %q{2010-03-29}
|
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}
|
data/lib/commit_hook.rb
CHANGED
@@ -18,8 +18,11 @@ class CommitHook
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.run(config, rev1, rev2, ref_name)
|
21
|
+
@config = {}
|
22
|
+
@config = YAML::load_file(config) if File.exist?(config)
|
23
|
+
|
21
24
|
project_path = Dir.getwd
|
22
|
-
recipient = Git.mailing_list_address
|
25
|
+
recipient = @config["mailinglist"] || Git.mailing_list_address
|
23
26
|
|
24
27
|
if (recipient.nil? || recipient.length == 0)
|
25
28
|
CommitHook.show_error(
|
@@ -31,13 +34,10 @@ class CommitHook
|
|
31
34
|
puts "Sending mail..."
|
32
35
|
STDOUT.flush
|
33
36
|
|
34
|
-
prefix = Git.repo_name
|
37
|
+
prefix = @config["emailprefix"] || Git.repo_name
|
35
38
|
branch_name = (ref_name =~ /master$/i) ? "" : "/#{ref_name.split("/").last}"
|
36
39
|
|
37
|
-
|
38
|
-
@config = YAML::load_file(config) if File.exist?(config)
|
39
|
-
|
40
|
-
diff2html = DiffToHtml.new(Dir.pwd)
|
40
|
+
diff2html = DiffToHtml.new(Dir.pwd, @config)
|
41
41
|
diff2html.diff_between_revisions rev1, rev2, prefix, ref_name
|
42
42
|
|
43
43
|
diffresult = diff2html.result
|
data/lib/diff_to_html.rb
CHANGED
@@ -7,11 +7,12 @@ def escape_content(s)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class DiffToHtml
|
10
|
-
attr_accessor :file_prefix
|
10
|
+
attr_accessor :file_prefix, :current_file_name
|
11
11
|
attr_reader :result
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@previous_dir =
|
13
|
+
def initialize(previous_dir = nil, config = nil)
|
14
|
+
@previous_dir = previous_dir
|
15
|
+
@config = config || {}
|
15
16
|
end
|
16
17
|
|
17
18
|
def range_info(range)
|
@@ -107,7 +108,14 @@ class DiffToHtml
|
|
107
108
|
else
|
108
109
|
op = "Changed"
|
109
110
|
end
|
110
|
-
|
111
|
+
|
112
|
+
file_name = @current_file_name
|
113
|
+
|
114
|
+
if (@config["link_files"] && @config["link_files"] == "gitweb" && @config["gitweb"])
|
115
|
+
file_name = "<a href='#{@config['gitweb']['path']}/gitweb?p=#{@config['gitweb']['project']};f=#{file_name};hb=head'>#{file_name}</a>"
|
116
|
+
end
|
117
|
+
|
118
|
+
header = "#{op} #{binary}file #{file_name}"
|
111
119
|
"<h2>#{header}</h2>\n"
|
112
120
|
end
|
113
121
|
|
@@ -286,7 +294,7 @@ class DiffToHtml
|
|
286
294
|
|
287
295
|
title = "<div class=\"title\">"
|
288
296
|
title += "<strong>Message:</strong> #{message_array_as_html commit_info[:message]}<br />\n"
|
289
|
-
title += "<strong>Commit
|
297
|
+
title += "<strong>Commit:</strong> #{commit_info[:commit]}<br />\n"
|
290
298
|
title += "<strong>Branch:</strong> #{branch}\n<br />" unless branch =~ /\/head/
|
291
299
|
title += "<strong>Date:</strong> #{CGI.escapeHTML commit_info[:date]}\n<br />"
|
292
300
|
title += "<strong>Author:</strong> #{CGI.escapeHTML(commit_info[:author])} <#{commit_info[:email]}>\n</div>"
|
data/lib/emailer.rb
CHANGED
@@ -5,8 +5,7 @@ require 'tamtam'
|
|
5
5
|
class Emailer
|
6
6
|
|
7
7
|
def initialize(config, project_path, recipient, from_address, from_alias, subject, text_message, html_diff, old_rev, new_rev, ref_name)
|
8
|
-
@config = config
|
9
|
-
@config ||= {}
|
8
|
+
@config = config || {}
|
10
9
|
@project_path = project_path
|
11
10
|
@recipient = recipient
|
12
11
|
@from_address = from_address
|
@@ -94,4 +94,23 @@ class DiffToHtmlTest < Test::Unit::TestCase
|
|
94
94
|
'key',',',' ','scope'], tokens
|
95
95
|
end
|
96
96
|
|
97
|
+
def test_operation_description
|
98
|
+
diff = DiffToHtml.new
|
99
|
+
diff.current_file_name = "file/to/test.yml"
|
100
|
+
assert_equal "<h2>Changed file file/to/test.yml</h2>\n", diff.operation_description
|
101
|
+
|
102
|
+
config = {
|
103
|
+
"link_files" => "gitweb",
|
104
|
+
"gitweb" => {
|
105
|
+
"path" => "http://developerserver/path_to_gitweb",
|
106
|
+
"project" => "test.git"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
diff = DiffToHtml.new(nil, config)
|
111
|
+
diff.current_file_name = "file/to/test.yml"
|
112
|
+
assert_equal "<h2>Changed file <a href='http://developerserver/path_to_gitweb/gitweb?p=test.git;f=file/to/test.yml;hb=head'>file/to/test.yml</a></h2>\n", diff.operation_description
|
113
|
+
|
114
|
+
end
|
115
|
+
|
97
116
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bodo Tasche
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-29 00:00:00 +02:00
|
18
18
|
default_executable: git-commit-notifier
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|