Skip to content

Commit d8fab49

Browse files
committed
Drop RSS support from commit-email
1 parent 4a27ad9 commit d8fab49

File tree

4 files changed

+5
-118
lines changed

4 files changed

+5
-118
lines changed

.travis.yml

-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,5 @@ script:
2020
cd ./ruby &&
2121
../bin/commit-email.rb ./ [email protected] \
2222
$(git rev-parse HEAD^) $(git rev-parse HEAD) refs/heads/trunk \
23-
--name Ruby \
2423
--viewer-uri "https://git.ruby-lang.org/ruby.git/commit/?id=" \
25-
-r https://svn.ruby-lang.org/repos/ruby \
26-
--rss-path /tmp/ruby.rdf \
27-
--rss-uri https://svn.ruby-lang.org/rss/ruby.rdf \
2824
--error-to [email protected]

bin/commit-email.rb

+5-106
Original file line numberDiff line numberDiff line change
@@ -152,46 +152,22 @@ class << CommitEmail
152152

153153
def parse(args)
154154
options = OpenStruct.new
155-
options.error_to = []
156-
options.repository_uri = nil
157-
options.rss_path = nil
158-
options.rss_uri = nil
159-
options.name = nil
155+
options.error_to = nil
160156
options.viewvc_uri = nil
161157

162158
opts = OptionParser.new do |opts|
163159
opts.separator('')
164160

165161
opts.on('-e', '--error-to [TO]',
166162
'Add [TO] to to address when error is occurred') do |to|
167-
options.error_to << to unless to.nil?
163+
options.error_to = to
168164
end
169165

170166
opts.on('--viewer-uri [URI]',
171167
'Use [URI] as URI of revision viewer') do |uri|
172168
options.viewer_uri = uri
173169
end
174170

175-
opts.on('-r', '--repository-uri [URI]',
176-
'Use [URI] as URI of repository') do |uri|
177-
options.repository_uri = uri
178-
end
179-
180-
opts.on('--rss-path [PATH]',
181-
'Use [PATH] as output RSS path') do |path|
182-
options.rss_path = path
183-
end
184-
185-
opts.on("--rss-uri [URI]",
186-
"Use [URI] as output RSS URI") do |uri|
187-
options.rss_uri = uri
188-
end
189-
190-
opts.on('--name [NAME]',
191-
'Use [NAME] as repository name') do |name|
192-
options.name = name
193-
end
194-
195171
opts.on_tail('--help', 'Show this message') do
196172
puts opts
197173
exit
@@ -216,21 +192,6 @@ def main(repo_path, to, rest)
216192

217193
from = info.author_email
218194
sendmail(to, from, make_mail(to, from, info, viewer_uri: options.viewer_uri))
219-
220-
if options.repository_uri and
221-
options.rss_path and
222-
options.rss_uri
223-
require 'rss/1.0'
224-
require 'rss/dublincore'
225-
require 'rss/content'
226-
require 'rss/maker'
227-
CommitEmail.extend(RSS::Utils)
228-
output_rss(options.name,
229-
options.rss_path,
230-
options.rss_uri,
231-
options.repository_uri,
232-
info)
233-
end
234195
end
235196
end
236197

@@ -394,71 +355,6 @@ def x_revision(info)
394355
def make_mail(to, from, info, viewer_uri:)
395356
"#{make_header(to, from, info)}\n#{make_body(info, viewer_uri: viewer_uri)}"
396357
end
397-
398-
def output_rss(name, file, rss_uri, repos_uri, info)
399-
prev_rss = nil
400-
begin
401-
if File.exist?(file)
402-
File.open(file) do |f|
403-
prev_rss = RSS::Parser.parse(f)
404-
end
405-
end
406-
rescue RSS::Error
407-
end
408-
409-
File.open(file, 'w') do |f|
410-
f.print(make_rss(prev_rss, name, rss_uri, repos_uri, info).to_s)
411-
end
412-
end
413-
414-
def make_rss(base_rss, name, rss_uri, repos_uri, info)
415-
RSS::Maker.make('1.0') do |maker|
416-
maker.encoding = 'UTF-8'
417-
418-
maker.channel.about = rss_uri
419-
maker.channel.title = rss_title(name || repos_uri)
420-
maker.channel.link = repos_uri
421-
maker.channel.description = rss_title(name || repos_uri)
422-
maker.channel.dc_date = info.date
423-
424-
if base_rss
425-
base_rss.items.each do |item|
426-
item.setup_maker(maker)
427-
end
428-
end
429-
430-
diff_info(info, repos_uri).each do |name, infos|
431-
infos.each do |desc, link|
432-
item = maker.items.new_item
433-
item.title = name
434-
item.description = desc
435-
item.content_encoded = "<pre>#{h(desc)}</pre>"
436-
item.link = link
437-
item.dc_date = info.date
438-
item.dc_creator = info.author
439-
end
440-
end
441-
442-
maker.items.do_sort = true
443-
maker.items.max_size = 15
444-
end
445-
end
446-
447-
def rss_title(name)
448-
"Repository of #{name}"
449-
end
450-
451-
def rss_items(items, info, repos_uri)
452-
diff_info(info, repos_uri).each do |name, infos|
453-
infos.each do |desc, link|
454-
items << [link, name, desc, info.date]
455-
end
456-
end
457-
458-
items.sort_by do |uri, title, desc, date|
459-
date
460-
end.reverse
461-
end
462358
end
463359

464360
repo_path, to, *rest = ARGV
@@ -467,6 +363,9 @@ def rss_items(items, info, repos_uri)
467363
rescue StandardError => e
468364
$stderr.puts "#{e.class}: #{e.message}"
469365
$stderr.puts e.backtrace
366+
367+
_, options = CommitEmail.parse(rest)
368+
to = options.error_to
470369
CommitEmail.sendmail(to, to, <<-MAIL)
471370
From: #{to}
472371
To: #{to}

hooks/post-receive-pre.sh

-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ log "args: $*"
2424
# log "==> commit-email.rb"
2525
# "${ruby_commit_hook}/bin/commit-email.rb" \
2626
# "$ruby_git" [email protected] $* \
27-
# --name Ruby \
2827
# --viewer-uri "https://git.ruby-lang.org/ruby.git/commit/?id=" \
29-
# -r https://svn.ruby-lang.org/repos/ruby \
30-
# --rss-path /tmp/ruby.rdf \
31-
# --rss-uri https://svn.ruby-lang.org/rss/ruby.rdf \
3228
# --error-to [email protected]
3329

3430
log "==> redmine fetch changesets"

hooks/post-receive.sh

-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ log "==> notify slack"
2323
log "==> commit-email.rb"
2424
"${ruby_commit_hook}/bin/commit-email.rb" \
2525
"$ruby_git" [email protected] $* \
26-
--name Ruby \
2726
--viewer-uri "https://git.ruby-lang.org/ruby.git/commit/?id=" \
28-
-r https://svn.ruby-lang.org/repos/ruby \
29-
--rss-path /tmp/ruby.rdf \
30-
--rss-uri https://svn.ruby-lang.org/rss/ruby.rdf \
3127
--error-to [email protected]
3228

3329
log "==> redmine fetch changesets"

0 commit comments

Comments
 (0)