Sha256: 84ccfd57d20aeb4f6507c606d15a9147ba2792e44db6a95eb78131db4c9dadc2

Contents?: true

Size: 1.99 KB

Versions: 13

Compression:

Stored size: 1.99 KB

Contents

require "rake"
require "rake/tasklib"
require "github_changelog_generator"

module GitHubChangelogGenerator
  class RakeTask < ::Rake::TaskLib
    include ::Rake::DSL if defined?(::Rake::DSL)

    OPTIONS = %w( user project token date_format output
                  bug_prefix enhancement_prefix issue_prefix
                  header merge_prefix issues
                  add_issues_wo_labels add_pr_wo_labels
                  pulls filter_issues_by_milestone author
                  unreleased_only unreleased unreleased_label
                  compare_link include_labels exclude_labels
                  bug_labels enhancement_labels
                  between_tags exclude_tags since_tag max_issues
                  github_site github_endpoint simple_list
                  future_release release_branch verbose release_url
                  base )

    OPTIONS.each do |o|
      attr_accessor o.to_sym
    end

    # Public: Initialise a new GitHubChangelogGenerator::RakeTask.
    #
    # Example
    #
    #   GitHubChangelogGenerator::RakeTask.new
    def initialize(*args, &task_block)
      @name = args.shift || :changelog

      define(args, &task_block)
    end

    def define(args, &task_block)
      desc "Generate a Change log from GitHub"

      yield(*[self, args].slice(0, task_block.arity)) if task_block

      # clear any (auto-)pre-existing task
      Rake::Task[@name].clear if Rake::Task.task_defined?(@name)

      task @name do
        # mimick parse_options
        options = Parser.default_options

        Parser.user_and_project_from_git(options)

        OPTIONS.each do |o|
          v = instance_variable_get("@#{o}")
          options[o.to_sym] = v unless v.nil?
        end

        generator = Generator.new options

        log = generator.compound_changelog

        output_filename = (options[:output]).to_s
        File.open(output_filename, "w") { |file| file.write(log) }
        puts "Done!"
        puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
github_changelog_generator-1.13.0 lib/github_changelog_generator/task.rb
github_changelog_generator-1.12.1 lib/github_changelog_generator/task.rb
changelog_jira-1.12.0 lib/github_changelog_generator/task.rb
github_changelog_generator-1.12.0 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.8 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.7 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.6 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.5 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.4 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.3 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.2 lib/github_changelog_generator/task.rb
github_changelog_generator-1.11.1 lib/github_changelog_generator/task.rb
github_changelog_generator-1.10.4 lib/github_changelog_generator/task.rb