dtas.git  about / heads / tags
duct tape audio suite for *nix
blob 30316acf30c4501223bc9f08cdf92210300017d9 1487 bytes (raw)
$ git show 0.12.x-stable:Documentation/update-footer.rb	# shows this blob on the CLI

 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
 
#!/usr/bin/env ruby
# Copyright 2015 all contributors <dtas-all@nongnu.org>
# License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
contact = %q{
All feedback welcome via plain-text mail to: <dtas-all@nongnu.org>\
Mailing list archives available at <http://80x24.org/dtas-all/> and
<ftp://lists.gnu.org/dtas-all/>\
No subscription is necessary to post to the mailing list.
}

copyright = %q{
Copyright %s all contributors <dtas-all@nongnu.org>.\
License: GPLv3 or later <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 --reverse --pretty=format:%ad --date=short -- #{file})
  beg_year = IO.popen(cmd, &:gets).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 => "" }
    fp.each_line do |l|
      case l
      when /^(#.+)$/
        state = $1.freeze
        sections << state
        sec[state] = ""
      else
        sec[state] << l
      end
    end

    fp.truncate(0)
    fp.rewind
    sec["# CONTACT"] = contact
    sec["# 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

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git