<commit_before>require File.join(File.dirname(__FILE__), "../gitorious")

def each_version
  pattern = /^v(\d+\.\d+\.\d+)/

  `#{ENV["GIT"] || "git"} tag -n`.split("\n").reverse.each do |line|
    next unless line =~ pattern
    nothing, version, *description = line.split(pattern)
    yield version, description.join
  end
end

def list_versions
  puts "\nAvailable versions"
  newest = true

  each_version do |version, description|
    color = newest ? "32" : "31"
    newest = false

    if Gitorious::VERSION == version
      print "-> \033[1m\033[#{color}mv#{version}\033[0m"
    else
      print "   v#{version}"
    end

    puts "    #{description}"
  end
end

def describe_version(version)
  puts "\nChanges between v#{Gitorious::VERSION} and v#{version}:"

  each_version do |v, description|
    next if v <= Gitorious::VERSION || v > version
    puts v
    puts `#{ENV['GIT'] || 'git'} tag -l v#{v} -n9999`.split("\n")[2..-1].join("\n")
  end
end

desc "Show current and available Gitorious versions and details about individual versions"
task :changelog do
  system("#{ENV['GIT'] || 'git'} fetch git://gitorious.org/gitorious/mainline.git 2> /dev/null")

  if ENV["VERSION"]
    describe_version(ENV["VERSION"])
  else
    list_versions
  end
end<commit_msg>Add rake task for displaying unreleased commits<commit_after>require File.join(File.dirname(__FILE__), "../gitorious")

def each_version
  pattern = /^v(\d+\.\d+\.\d+)/

  `#{ENV["GIT"] || "git"} tag -n`.split("\n").reverse.each do |line|
    next unless line =~ pattern
    nothing, version, *description = line.split(pattern)
    yield version, description.join
  end
end

def list_versions
  puts "\nAvailable versions"
  newest = true

  each_version do |version, description|
    color = newest ? "32" : "31"
    newest = false

    if Gitorious::VERSION == version
      print "-> \033[1m\033[#{color}mv#{version}\033[0m"
    else
      print "   v#{version}"
    end

    puts "    #{description}"
  end
end

def describe_version(version)
  puts "\nChanges between v#{Gitorious::VERSION} and v#{version}:"

  each_version do |v, description|
    next if v <= Gitorious::VERSION || v > version
    puts v
    puts `#{ENV['GIT'] || 'git'} tag -l v#{v} -n9999`.split("\n")[2..-1].join("\n")
  end
end

def show_changelog
  system("#{ENV['GIT'] || 'git'} fetch git://gitorious.org/gitorious/mainline.git 2> /dev/null")

  if ENV["VERSION"]
    describe_version(ENV["VERSION"])
  else
    list_versions
  end
end


task :changelog do
  show_changelog
end

namespace :versioning do
  desc "List commits not versioned yet"
  task :unreleased do
    log_spec = "v#{Gitorious::VERSION}..HEAD"
    command = %Q[#{ENV['GIT'] || "git"} log #{log_spec}]
    header = "Commits not yet versioned in Gitorious:"
    puts "\n#{header}"
    puts "=" * header.size + "\n"
    exec command
  end

  desc "Show current and available Gitorious versions and details about individual versions"
  task :changelog do
    show_changelog
  end
end
{'fraction_non_alphanumeric': 0.15615615615615616, 'fraction_numerical': 0.014681348014681348, 'mean_word_length': 3.4153166421207657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6578734', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1035, 'n_words': 275}