Sha256: 991b640f33a7b7fdfd5fef0ff53815dd40fdad990b789405d8bd458abc85d602

Contents?: true

Size: 1.11 KB

Versions: 21

Compression:

Stored size: 1.11 KB

Contents

require "omnibus/git_repository"

module Omnibus
  class ChangeLog
    CHANGELOG_TAG = "ChangeLog-Entry".freeze

    attr_reader :end_ref
    def initialize(start_ref = nil, end_ref = "HEAD", git_repo = GitRepository.new("./"))
      @start_ref = start_ref
      @end_ref = end_ref
      @git_repo = git_repo
    end

    def authors
      git_repo.authors(start_ref, end_ref)
    end

    def changelog_entries
      entries = []
      current_entry = []
      git_repo.commit_messages(start_ref, end_ref).each do |l|
        if blank?(l)
          entries << current_entry
          current_entry = []
        elsif tagged?(l)
          entries << current_entry
          current_entry = Array(l.sub(/^#{CHANGELOG_TAG}:[\s]*/, ""))
        elsif !current_entry.empty?
          current_entry << l
        end
      end
      entries << current_entry
      entries.reject(&:empty?).map(&:join)
    end

    def start_ref
      @start_ref ||= git_repo.latest_tag
    end

    private

    attr_reader :git_repo

    def blank?(line)
      line =~ /^[\s]*$/
    end

    def tagged?(line)
      line =~ /^#{CHANGELOG_TAG}:/
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
omnibus-9.0.24 lib/omnibus/changelog.rb
omnibus-9.0.23 lib/omnibus/changelog.rb
omnibus-9.0.22 lib/omnibus/changelog.rb
omnibus-9.0.17 lib/omnibus/changelog.rb
omnibus-9.0.12 lib/omnibus/changelog.rb
omnibus-9.0.11 lib/omnibus/changelog.rb
omnibus-9.0.8 lib/omnibus/changelog.rb
omnibus-8.3.2 lib/omnibus/changelog.rb
omnibus-8.2.2 lib/omnibus/changelog.rb
omnibus-8.1.15 lib/omnibus/changelog.rb
omnibus-8.0.15 lib/omnibus/changelog.rb
omnibus-8.0.9 lib/omnibus/changelog.rb
omnibus-7.0.34 lib/omnibus/changelog.rb
omnibus-7.0.13 lib/omnibus/changelog.rb
omnibus-7.0.12 lib/omnibus/changelog.rb
omnibus-6.1.9 lib/omnibus/changelog.rb
omnibus-6.1.7 lib/omnibus/changelog.rb
omnibus-6.1.4 lib/omnibus/changelog.rb
omnibus-6.0.30 lib/omnibus/changelog.rb
omnibus-6.0.25 lib/omnibus/changelog.rb