git-commit-notifier 0.11.9 → 0.11.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -5
- data/CHANGES.md +41 -0
- data/README.md +7 -0
- data/VERSION +1 -1
- data/config/git-notifier-config.example.yml +16 -2
- data/lib/git_commit_notifier/commit_hook.rb +11 -2
- data/lib/git_commit_notifier/diff_to_html.rb +7 -8
- data/lib/git_commit_notifier/emailer.rb +1 -1
- data/lib/git_commit_notifier/git.rb +15 -3
- data/spec/lib/git_commit_notifier/commit_hook_spec.rb +1 -0
- metadata +4 -3
data/.travis.yml
CHANGED
data/CHANGES.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
## Not yet released
|
4
|
+
|
5
|
+
* Display info message if the config.yml specified is not found.
|
6
|
+
* Strip whitespace after splitting emails for SMTP.
|
7
|
+
* Added prefer_git_config_mailinglist config variable.
|
8
|
+
* Allow to use one configuarion per all cgit projects.
|
9
|
+
* Support for Gitalist.
|
10
|
+
|
11
|
+
## Version 0.11.9
|
12
|
+
|
13
|
+
* Notifier now do not falls on invalid utf-8 text in diffs.
|
14
|
+
* Fixes erroneous 0.11.7 release (partially incomplete code was pushed to rubygems and breaks ruby 1.8 compatibility).
|
15
|
+
|
16
|
+
## Version 0.11.7
|
17
|
+
|
18
|
+
* Summary email section has been updated to be shown correctly.
|
19
|
+
* More fine-grained values for ignore_whitespace option (all, change, none).
|
20
|
+
* Add support for gitlabhq 4.0+ namespace repo arrangement.
|
21
|
+
* Correct urls to cgit installations.
|
22
|
+
* Correct Trac integration.
|
23
|
+
* Support for GitHub WebHooks (as client).
|
24
|
+
* Fix mailformed tag notifications.
|
25
|
+
* A lot of other fixes.
|
26
|
+
|
27
|
+
## Version 0.11.6
|
28
|
+
|
29
|
+
* Project home has been moved to git-commit-notifier GitHub organization.
|
30
|
+
|
31
|
+
## Version 0.11.5
|
32
|
+
|
33
|
+
* Support for GitHub-flavoured WebHooks (as server).
|
34
|
+
* Ability to reply_to_author.
|
35
|
+
* Shows summary.
|
36
|
+
* Do not send additional email on branch creation.
|
37
|
+
|
38
|
+
## Versions 0.11.0 - 0.11.4
|
39
|
+
|
40
|
+
* Fix segmentation faults with Unicode subjects on Ruby 1.9
|
41
|
+
* A lot of refactorings.
|
data/README.md
CHANGED
@@ -61,6 +61,13 @@ If you want to send mails on each commit instead on each push, you should add a
|
|
61
61
|
echo "HEAD^1 HEAD refs/heads/master" | git-commit-notifier path_to_config.yml
|
62
62
|
```
|
63
63
|
|
64
|
+
## Decorate files and commit ids with link to a webview
|
65
|
+
You need change next line in config file ```link_files: none```
|
66
|
+
|
67
|
+
Possible values: none, gitweb, gitorious, cgit, trac, gitlabhq, or redmine
|
68
|
+
|
69
|
+
* "cgit" you can omit "project". In this case repository name will be used by default
|
70
|
+
|
64
71
|
## Integration with Redmine, Bugzilla, MediaWiki
|
65
72
|
|
66
73
|
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).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.10
|
@@ -56,6 +56,12 @@ show_summary: true
|
|
56
56
|
# It can send to multiple destinations, just separate email addresses by ",".
|
57
57
|
mailinglist: developers@example.com,dev2@example.com,dev3@example.com,cto@example.com
|
58
58
|
|
59
|
+
# If set to true, the notifier will check first for a git config hooks.mailinglist
|
60
|
+
# variable and use the recipients listed there before checking for the recipient(s)
|
61
|
+
# listed above. If false, uses the receipient(s) above if defined, regardless
|
62
|
+
# of the git config variable. Defaults to false.
|
63
|
+
prefer_git_config_mailinglist: false
|
64
|
+
|
59
65
|
# The from address. If not defined it will use
|
60
66
|
# the address that is configured in git
|
61
67
|
# from: sender@example.com
|
@@ -109,7 +115,7 @@ nntp_settings:
|
|
109
115
|
port: 119
|
110
116
|
|
111
117
|
# Decorate files and commit ids with link to a webview. Possible values: none, gitweb,
|
112
|
-
# gitorious, cgit, trac, gitlabhq, or redmine
|
118
|
+
# gitorious, cgit, trac, gitlabhq, gitalist or redmine
|
113
119
|
link_files: none
|
114
120
|
|
115
121
|
# If link_files is set to "gitweb", you need to configure the path to your gitweb
|
@@ -128,7 +134,9 @@ gitorious:
|
|
128
134
|
# if link_files is set to "cgit", you need to configure the path to your cgit
|
129
135
|
cgit:
|
130
136
|
path: http://example.com/path_to_cgit
|
131
|
-
project:
|
137
|
+
project: project-name
|
138
|
+
# project defaults to git repository name
|
139
|
+
|
132
140
|
|
133
141
|
# If link_files is set to "trac", you need to configure the path to your trac
|
134
142
|
# instance
|
@@ -141,6 +149,12 @@ gitlabhq:
|
|
141
149
|
path: http://gitlabhq.example.com
|
142
150
|
version: 1.2
|
143
151
|
|
152
|
+
# If link_files is set to "gitalist", you need to configure the path to your gitalist
|
153
|
+
# instance
|
154
|
+
gitalist:
|
155
|
+
path: http://gitalist.example.com
|
156
|
+
project: test.git
|
157
|
+
|
144
158
|
# If link_files is set to "redmine", you need to configure the path to your redmine
|
145
159
|
# instance
|
146
160
|
redmine:
|
@@ -85,7 +85,12 @@ module GitCommitNotifier
|
|
85
85
|
def run(config_name, rev1, rev2, ref_name)
|
86
86
|
|
87
87
|
# Load the configuration
|
88
|
-
|
88
|
+
if File.exists?(config_name)
|
89
|
+
@config = YAML::load_file(config_name)
|
90
|
+
else
|
91
|
+
GitCommitNotifier::CommitHook.info("Unable to find configuration file: #{config_name}")
|
92
|
+
@config = {}
|
93
|
+
end
|
89
94
|
|
90
95
|
project_path = Git.git_dir
|
91
96
|
repo_name = Git.repo_name
|
@@ -100,7 +105,11 @@ module GitCommitNotifier
|
|
100
105
|
slash_branch_name = "" if !config["show_master_branch_name"] && slash_branch_name == '/master'
|
101
106
|
|
102
107
|
# Identify email recipients
|
103
|
-
|
108
|
+
if config["prefer_git_config_mailinglist"]
|
109
|
+
recipient = Git.mailing_list_address || config["mailinglist"]
|
110
|
+
else
|
111
|
+
recipient = config["mailinglist"] || Git.mailing_list_address
|
112
|
+
end
|
104
113
|
|
105
114
|
# If no recipients specified, bail out gracefully. This is not an error, and might be intentional
|
106
115
|
if recipient.nil? || recipient.length == 0
|
@@ -11,8 +11,6 @@ module GitCommitNotifier
|
|
11
11
|
class DiffToHtml
|
12
12
|
include EscapeHelper
|
13
13
|
|
14
|
-
|
15
|
-
|
16
14
|
# Integration map for commit message keywords to third-party links.
|
17
15
|
INTEGRATION_MAP = {
|
18
16
|
:mediawiki => { :search_for => /\[\[([^\[\]]+)\]\]/, :replace_with => '#{url}/\1' },
|
@@ -192,11 +190,9 @@ module GitCommitNotifier
|
|
192
190
|
|
193
191
|
file_name = @current_file_name
|
194
192
|
|
195
|
-
text = "#{op} #{binary}file #{file_name}"
|
196
|
-
|
197
193
|
# TODO: these filenames, etc, should likely be properly html escaped
|
198
194
|
file_link = file_name
|
199
|
-
if config['link_files']
|
195
|
+
if config['link_files'] && !@file_removed
|
200
196
|
file_link = if config["link_files"] == "gitweb" && config["gitweb"]
|
201
197
|
"<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>"
|
202
198
|
elsif config["link_files"] == "gitorious" && config["gitorious"]
|
@@ -204,7 +200,7 @@ module GitCommitNotifier
|
|
204
200
|
elsif config["link_files"] == "trac" && config["trac"]
|
205
201
|
"<a href='#{config['trac']['path']}/#{@current_commit}/#{file_name}'>#{file_name}</a>"
|
206
202
|
elsif config["link_files"] == "cgit" && config["cgit"]
|
207
|
-
"<a href='#{config['cgit']['path']}/#{config['cgit']['project']}/tree/#{file_name}?h=#{branch_name}'>#{file_name}</a>"
|
203
|
+
"<a href='#{config['cgit']['path']}/#{config['cgit']['project'] || "#{Git.repo_name_real}"}/tree/#{file_name}?h=#{branch_name}'>#{file_name}</a>"
|
208
204
|
elsif config["link_files"] == "gitlabhq" && config["gitlabhq"]
|
209
205
|
if config["gitlabhq"]["version"] && config["gitlabhq"]["version"] < 1.2
|
210
206
|
"<a href='#{config['gitlabhq']['path']}/#{Git.repo_name.gsub(".", "_")}/tree/#{@current_commit}/#{file_name}'>#{file_name}</a>"
|
@@ -213,6 +209,8 @@ module GitCommitNotifier
|
|
213
209
|
else
|
214
210
|
"<a href='#{config['gitlabhq']['path']}/#{Git.repo_name.gsub(".", "_")}/#{@current_commit}/tree/#{file_name}'>#{file_name}</a>"
|
215
211
|
end
|
212
|
+
elsif config["link_files"] == "gitalist" && config["gitalist"]
|
213
|
+
"<a href='#{config['gitalist']['path']}/#{config['gitalist']['project'] || Git.repo_name}/#{@current_commit}/blob/#{file_name}'>#{file_name}</a>"
|
216
214
|
elsif config["link_files"] == "redmine" && config["redmine"]
|
217
215
|
"<a href='#{config['redmine']['path']}/projects/#{config['redmine']['project'] || Git.repo_name}/repository/revisions/#{@current_commit}/entry/#{file_name}'>#{file_name}</a>"
|
218
216
|
else
|
@@ -223,7 +221,7 @@ module GitCommitNotifier
|
|
223
221
|
if show_summary?
|
224
222
|
@file_changes << {
|
225
223
|
:file_name => file_name,
|
226
|
-
:text =>
|
224
|
+
:text => "#{op} #{binary}file #{file_name}",
|
227
225
|
}
|
228
226
|
end
|
229
227
|
|
@@ -508,8 +506,9 @@ module GitCommitNotifier
|
|
508
506
|
:gitweb => lambda { |config, commit| "<a href='#{config['gitweb']['path']}?p=#{config['gitweb']['project'] || "#{Git.repo_name}.git"};a=commitdiff;h=#{commit}'>#{commit}</a>" },
|
509
507
|
:gitorious => lambda { |config, commit| "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/commit/#{commit}'>#{commit}</a>" },
|
510
508
|
:trac => lambda { |config, commit| "<a href='#{config['trac']['path']}/#{commit}'>#{commit}</a>" },
|
511
|
-
:cgit => lambda { |config, commit| "<a href='#{config['cgit']['path']}/#{config['cgit']['project']}/commit/?id=#{commit}'>#{commit}</a>" },
|
509
|
+
:cgit => lambda { |config, commit| "<a href='#{config['cgit']['path']}/#{config['cgit']['project'] || "#{Git.repo_name_real}"}/commit/?id=#{commit}'>#{commit}</a>" },
|
512
510
|
:gitlabhq => lambda { |config, commit| "<a href='#{config['gitlabhq']['path']}/#{Git.repo_name.gsub(".", "_")}/commits/#{commit}'>#{commit}</a>" },
|
511
|
+
:gitalist => lambda { |config, commit| "<a href='#{config['gitalist']['path']}/projects/#{config['gitalist']['project'] || Git.repo_name}/#{commit}/log'>#{commit}</a>" },
|
513
512
|
:redmine => lambda { |config, commit| "<a href='#{config['redmine']['path']}/projects/#{config['redmine']['project'] || Git.repo_name}/repository/revisions/#{commit}'>#{commit}</a>" },
|
514
513
|
:default => lambda { |config, commit| commit.to_s }
|
515
514
|
}.freeze
|
@@ -136,7 +136,7 @@ class GitCommitNotifier::Emailer
|
|
136
136
|
|
137
137
|
recipients = @recipient.dup
|
138
138
|
recipients.force_encoding('ASCII-8BIT') if recipients.respond_to?(:force_encoding)
|
139
|
-
recipients = recipients.split(",")
|
139
|
+
recipients = recipients.split(",").map(&:strip)
|
140
140
|
smtp.open_message_stream(@from_address, recipients) do |f|
|
141
141
|
content.each do |line|
|
142
142
|
line.force_encoding('ASCII-8BIT') if line.respond_to?(:force_encoding)
|
@@ -72,13 +72,14 @@ class GitCommitNotifier::Git
|
|
72
72
|
# splits the output of changed_files
|
73
73
|
# @return [Hash(Array)] file names sorted by status
|
74
74
|
# @see changed_files
|
75
|
-
# @param [
|
75
|
+
# @param [String] rev1 First revision
|
76
|
+
# @param [String] rev2 Second revision
|
76
77
|
def split_status(rev1, rev2)
|
77
78
|
lines = changed_files(rev1, rev2)
|
78
79
|
modified = lines.map { |l| l.gsub(/M\s/,'').strip if l[0,1] == 'M' }.select { |l| !l.nil? }
|
79
80
|
added = lines.map { |l| l.gsub(/A\s/,'').strip if l[0,1] == 'A' }.select { |l| !l.nil? }
|
80
81
|
deleted = lines.map { |l| l.gsub(/D\s/,'').strip if l[0,1] == 'D' }.select { |l| !l.nil? }
|
81
|
-
|
82
|
+
{ :m => modified, :a => added, :d => deleted }
|
82
83
|
end
|
83
84
|
|
84
85
|
def branch_commits(treeish)
|
@@ -138,7 +139,7 @@ class GitCommitNotifier::Git
|
|
138
139
|
|
139
140
|
# Get all the commits that match that specification
|
140
141
|
lines = lines_from_shell("git rev-list --reverse #{a.join(' ')}")
|
141
|
-
|
142
|
+
lines.to_a.map { |l| l.chomp }
|
142
143
|
end
|
143
144
|
|
144
145
|
def rev_type(rev)
|
@@ -180,6 +181,17 @@ class GitCommitNotifier::Git
|
|
180
181
|
File.expand_path(git_path).split("/").last.sub(/\.git$/, '')
|
181
182
|
end
|
182
183
|
|
184
|
+
# Gets repository name.
|
185
|
+
# @return [String] Repository name.
|
186
|
+
def repo_name_real
|
187
|
+
git_path = toplevel_dir
|
188
|
+
# In a bare repository, toplevel directory is empty. Revert to git_dir instead.
|
189
|
+
if git_path.empty?
|
190
|
+
git_path = git_dir
|
191
|
+
end
|
192
|
+
File.expand_path(git_path).split("/").last
|
193
|
+
end
|
194
|
+
|
183
195
|
# Gets repository name.
|
184
196
|
# @note Tries to gets human readable repository name through `git config hooks.emailprefix` call.
|
185
197
|
# If it's not specified then returns directory name with parent directory name (except '.git'
|
@@ -111,6 +111,7 @@ describe GitCommitNotifier::CommitHook do
|
|
111
111
|
describe :run do
|
112
112
|
it "should report informational message when no recipients specified" do
|
113
113
|
mock(File).exists?(:noconfig) { false }
|
114
|
+
mock(GitCommitNotifier::CommitHook).info(/Unable to find/)
|
114
115
|
mock(GitCommitNotifier::Git).mailing_list_address { nil }
|
115
116
|
mock(GitCommitNotifier::CommitHook).info(/recipient/)
|
116
117
|
GitCommitNotifier::CommitHook.run(:noconfig, :rev1, :rev2, 'master')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-commit-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: diff-lcs
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- .rspec
|
275
275
|
- .travis.yml
|
276
276
|
- .yardopts
|
277
|
+
- CHANGES.md
|
277
278
|
- Gemfile
|
278
279
|
- LICENSE
|
279
280
|
- README.md
|
@@ -338,7 +339,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
338
339
|
version: '0'
|
339
340
|
segments:
|
340
341
|
- 0
|
341
|
-
hash:
|
342
|
+
hash: -83889522611154396
|
342
343
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
343
344
|
none: false
|
344
345
|
requirements:
|