blob: dfc1b1ad98a4c60814319822cbb3b39e7b9fc453 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/env ruby
# Copyright 2015-2016 all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <http://www.gnu.org/licenses/gpl-3.0.txt>
# frozen_string_literal: true
contact = %q{
All feedback welcome via plain-text mail to: L<mailto:dtas-all@nongnu.org>
Mailing list archives available at L<http://80x24.org/dtas-all/>
and L<ftp://lists.gnu.org/dtas-all/>
No subscription is necessary to post to the mailing list.
}
copyright = %q{
Copyright %s all contributors L<mailto:dtas-all@nongnu.org>
License: GPL-3.0+ L<http://www.gnu.org/licenses/gpl-3.0.txt>
}
ENV['TZ'] = 'UTC'
now_year = Time.now.strftime("%Y")
ARGV.each do |file|
cmd = %W(git log --follow -M1 --pretty=format:%ad --date=short
-- #{file})
beg_year = IO.popen(cmd, &:read).split("\n")[-1].split('-')[0]
years = beg_year == now_year ? beg_year : "#{beg_year}-#{now_year}"
File.open(file, "r+") do |fp|
state = :top
sections = [ state ]
sec = { state => ''.dup }
fp.each_line do |l|
case l
when /^(=head.+)$/
state = $1.freeze
sections << state
sec[state] = ''.dup
else
sec[state] << l
end
end
fp.truncate(0)
fp.rewind
sec["=head1 CONTACT"] = contact
sec["=head1 COPYRIGHT"] = sprintf(copyright, years)
while section = sections.shift
fp.puts(section) if String === section
blob = sec[section].sub(/\A\n+/, '').sub(/\n+\z/, '')
fp.puts("\n") if String === section
fp.write(blob)
fp.puts("\n")
fp.puts("\n") if sections[0]
end
fp.rewind
end
end
|