Sha256: e9920444b6d0c73dfe4ee1c7aaa96d74edc29e3b589f201d4a9a02cd7762a3a4

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require "fileutils"

# Helper method to insert text after a line that matches the regex
def insert_after_line(file, insert, regex = /^## Next/)
  tempfile = File.open("#{file}.tmp", "w")
  f = File.new(file)
  f.each do |line|
    tempfile << line
    next unless line =~ regex

    tempfile << "\n"
    tempfile << insert
    tempfile << "\n"
  end
  f.close
  tempfile.close

  FileUtils.mv("#{file}.tmp", file)
end

# Extracts all changes that have been made after the latest pushed tag
def changes_since_last_tag
  `git --no-pager log $(git describe --tags --abbrev=0)..HEAD --grep="Merge" --pretty=format:"%t - %s%n%b%n"`
end

# Extracts all github users contributed since last tag
def users_since_last_tag
  `git --no-pager log $(git describe --tags --abbrev=0)..HEAD --grep="Merge" --pretty=format:"%s" | cut -d' ' -f 6 | cut -d/ -f1 | uniq`
end

namespace :changelog do
  task :generate do
    insert_after_line("CHANGELOG.md", changes_since_last_tag, /^## Next/)
    printf("Users contributed since last release:\n")
    printf(users_since_last_tag)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-google-1.12.0 tasks/changelog.rake
fog-google-1.11.0 tasks/changelog.rake