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
58
59
60
|
# Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'tempfile'
include Rake::DSL
task "NEWS" do
latest = nil
fp = Tempfile.new("NEWS", ".")
fp.sync = true
`git tag -l`.split(/\n/).reverse.each do |tag|
%r{\Av(.+)} =~ tag or next
version = $1
header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
header = header.split(/\n/)
tagger = header.grep(/\Atagger /)[0]
time = Time.at(tagger.split(/ /)[-2].to_i).utc
latest ||= time
date = time.strftime("%Y-%m-%d")
fp.puts "# #{version} / #{date}\n\n#{subject}"
if body && body.strip.size > 0
fp.puts "\n\n#{body}"
end
fp.puts
end
fp.puts "Unreleased" unless fp.size > 0
fp.puts "# COPYRIGHT"
bdfl = 'Eric Wong <e@80x24.org>'
fp.puts "Copyright (C) 2013, #{bdfl} and all contributors"
fp.puts "License: GPLv3 or later (http://www.gnu.org/licenses/gpl-3.0.txt)"
fp.rewind
assert_equal fp.read, File.read("NEWS") rescue nil
fp.chmod 0644
File.rename(fp.path, "NEWS")
fp.close!
end
task rsync_docs: "NEWS" do
dest = ENV["RSYNC_DEST"] || "80x24.org:/srv/dtas/"
top = %w(INSTALL NEWS README COPYING)
files = []
# git-set-file-times is distributed with rsync,
# Also available at: http://yhbt.net/git-set-file-times
# on Debian systems: /usr/share/doc/rsync/scripts/git-set-file-times.gz
sh("git", "set-file-times", "Documentation", "examples", *top)
`git ls-files Documentation/*.txt`.split(/\n/).concat(top).each do |txt|
gz = "#{txt}.gz"
tmp = "#{gz}.#$$"
sh("gzip -9 < #{txt} > #{tmp}")
st = File.stat(txt)
File.utime(st.atime, st.mtime, tmp) # make nginx gzip_static happy
File.rename(tmp, gz)
files << txt
files << gz
end
sh("rsync --chmod=Fugo=r -av #{files.join(' ')} #{dest}")
examples = `git ls-files examples`.split("\n")
sh("rsync --chmod=Fugo=r -av #{examples.join(' ')} #{dest}/examples/")
end
|