yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
blob e8e4af04715438ee4c35dd7e6db1a23d246977ac 2330 bytes (raw)
name: Rakefile 	 # note: path name is non-authoritative(*)

 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
61
62
63
64
65
66
67
68
69
70
71
72
 
# Copyright (C) 2013-2015 all contributors <yahns-public@yhbt.net>
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'tempfile'
include Rake::DSL

gendocs = %w(NEWS NEWS.atom.xml)
task rsync_docs: gendocs do
  dest = ENV["RSYNC_DEST"] || "yahns.yhbt.net:/srv/yahns/"
  top = %w(INSTALL HACKING README COPYING)

  # 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)

  do_gzip = lambda do |txt|
    gz = "#{txt}.gz"
    tmp = "#{gz}.#$$"
    sh("gzip --rsyncable -9 < #{txt} > #{tmp}")
    st = File.stat(txt)
    File.utime(st.atime, st.mtime, tmp) # make nginx gzip_static happy
    File.rename(tmp, gz)
    gz
  end

  files = `git ls-files Documentation/*.txt`.split(/\n/)
  files.concat(top)
  files.concat(gendocs)
  gzfiles = files.map { |txt| do_gzip.call(txt) }
  files.concat(gzfiles)

  sh("rsync --chmod=Fugo=r -av #{files.join(' ')} #{dest}")

  examples = `git ls-files examples`.split(/\n/)
  gzex = examples.map { |txt| do_gzip.call(txt) }
  examples.concat(gzex)

  sh("rsync --chmod=Fugo=r -av #{examples.join(' ')} #{dest}/examples/")
end

def tags
  timefmt = '%Y-%m-%dT%H:%M:%SZ'
  @tags ||= `git tag -l`.split(/\n/).map do |tag|
    if %r{\Av[\d\.]+} =~ tag
      header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
      header = header.split(/\n/)
      tagger = header.grep(/\Atagger /).first
      body ||= "initial"
      time = Time.at(tagger.split(/ /)[-2].to_i).utc
      {
        time_obj: time,
        time: time.strftime(timefmt),
        tagger_name: %r{^tagger ([^<]+)}.match(tagger)[1].strip,
        tagger_email: %r{<([^>]+)>}.match(tagger)[1].strip,
        id: `git rev-parse refs/tags/#{tag}`.chomp!,
        tag: tag,
        subject: subject,
        body: body,
      }
    end
  end.compact.sort { |a,b| b[:time] <=> a[:time] }
end

desc 'prints news as an Atom feed'
task "NEWS.atom.xml" do
  # gem install 'olddoc', 'olddoc prepare' has no API besides the
  # command-line.  This requires olddoc 1.1 or later.
  system('olddoc', 'prepare') or abort "olddoc prepare failed #$?"
end

desc 'prints news as a text file'
task 'NEWS' => 'NEWS.atom.xml'

debug log:

solving e8e4af0 ...
found e8e4af0 in https://yhbt.net/yahns.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).