cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob 655241165651ff01ffb5f105d169b914833afde2 3293 bytes (raw)
$ git show v1.4.3:Rakefile	# 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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
 
# this is only used for release-related tasks and should not
# be needed by normal development

require "nokogiri" # gem install nokogiri
include Rake::DSL if defined?(Rake::DSL)

url_base = "http://bogomips.org/cmogstored"
cgit_url = url_base + '.git'
git_url = 'git://bogomips.org/cmogstored.git'

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.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 do
  require 'nokogiri'
  new_tags = tags[0,10]
  puts(Nokogiri::XML::Builder.new do
    feed :xmlns => "http://www.w3.org/2005/Atom" do
      id! "#{url_base}/NEWS.atom.xml"
      title "cmogstored news"
      subtitle "alternative mogstored implementation for MogileFS"
      link! :rel => 'alternate', :type => 'text/plain',
            :href => "#{url_base}/NEWS"
      updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
      new_tags.each do |tag|
        entry do
          title tag[:subject]
          updated tag[:time]
          published tag[:time]
          author {
            name tag[:tagger_name]
            email tag[:tagger_email]
          }
          url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
          link! :rel => "alternate", :type => "text/html", :href =>url
          id! url
          message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/).first.strip
          content({:type =>:text}, message_only)
          content(:type =>:xhtml) { pre tag[:body] }
        end
      end
    end
  end.to_xml)
end

desc 'prints news as a text file'
task :news do
  tags.each do |tag|
    time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
    line = "#{tag[:tag].sub(/^v/, '')} / #{time}"
    puts line
    puts("-" * line.length)
    puts ""

    puts tag[:body].gsub(/^/m, "  ").gsub(/[ \t]+$/m, "")
    puts "" unless tag == tags.last
  end
end

desc "dump changelog to stdout"
task :changelog do
  since = "v1.0.0"

  puts "cmogstored changelog since #{since}"
  puts "Full changeset information is available at #{git_url}"
  puts "See NEWS file for a user-oriented summary of changes"
  puts ""

  cmd = %w(git log --pretty=medium --date=iso --decorate) << "#{since}.."
  system(*cmd) or abort $?
end

desc "compare dist tar.gz against contents in the git tree"
task :distcheck_git do
  tgz = ENV["TGZ"] or abort "TGZ= not specified"
  tgzfiles = `tar -ztf #{tgz}`.split(/\n/)
  tgzfiles.map! { |f| f.gsub!(%r{^[^/]+/}, '') }
  gitfiles = `git ls-files`.split(/\n/)
  gitonly = gitfiles - tgzfiles
  gitonly -= %w(build-aux/manpage-hack.mk)
  if gitonly[0]
    warn "The following files are missing from #{tgz}"
    warn ""
    gitonly.each { |f| warn f }
    exit(1)
  end
end

git clone https://yhbt.net/cmogstored.git