Sha256: 86b96eea0bf3d959a18cc76a219aa6f2f8c59ad858b74ecf0bba3c8362c9ca9f

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 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 | sort | uniq`
end

namespace :changelog do
  task :generate do
    insert_after_line("CHANGELOG.md", changes_since_last_tag, /^## Next/)
    contributors = users_since_last_tag.split("\n").map { |name| "@" + name }
    printf("Huge thanks to all our contributors 🎆\n")
    printf("Special thanks to: " + contributors.join(" ") + "\n")
    printf("\nI'll merge this and release the gem once all tests pass.\n")
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
fog-google-1.24.1 tasks/changelog.rake
fog-google-1.24.0 tasks/changelog.rake
fog-google-1.23.0 tasks/changelog.rake
fog-google-1.22.0 tasks/changelog.rake
fog-google-1.21.1 tasks/changelog.rake
fog-google-1.21.0 tasks/changelog.rake
fog-google-1.20.0 tasks/changelog.rake
fog-google-1.19.0 tasks/changelog.rake
fog-google-1.18.0 tasks/changelog.rake
fog-google-1.17.0 tasks/changelog.rake
fog-google-1.16.1 tasks/changelog.rake
fog-google-1.16.0 tasks/changelog.rake
fog-google-1.15.0 tasks/changelog.rake
fog-google-1.14.0 tasks/changelog.rake
gitlab-fog-google-1.14.0 tasks/changelog.rake
fog-google-1.13.0 tasks/changelog.rake
gitlab-fog-google-1.13.0 tasks/changelog.rake
fog-google-1.12.1 tasks/changelog.rake