Merge branch 'hotfix/update-changelog' into develop

This commit is contained in:
Petr Korolev 2016-03-22 14:38:51 +02:00
commit 1c37268c3d
14 changed files with 221 additions and 53 deletions

6
.gitignore vendored
View File

@ -1 +1,7 @@
bin/
!bin/git-generate-changelog
!bin/github_changelog_generator
pkg/
coverage/
.bundle
spec/*.lock

View File

@ -1,10 +1,11 @@
sudo: false
cache:
- bundler
language: ruby
before_install:
- gem update --system
- gem install bundler
rvm:
- 2.1.0
- 2.1
script: bundle exec rake checks
matrix:
include:
@ -13,6 +14,10 @@ matrix:
script:
- gem build github_changelog_generator
- gem install *.gem
- install: true
script:
- gem build github_changelog_generator
- bundle install --gemfile spec/install-gem-in-bundler.gemfile
notifications:
email:
recipients:

View File

@ -1,5 +1,36 @@
# Change Log
## [1.11.8](https://github.com/skywinder/github-changelog-generator/tree/1.11.8) (2016-03-22)
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.7...1.11.8)
**Implemented enhancements:**
- ParserFile: Allow comments in settings file [\#358](https://github.com/skywinder/github-changelog-generator/pull/358) ([olleolleolle](https://github.com/olleolleolle))
**Fixed bugs:**
- Error when specifying exclude\_labels [\#327](https://github.com/skywinder/github-changelog-generator/issues/327)
- Parse options file options into arrays, integers, flags, and other [\#354](https://github.com/skywinder/github-changelog-generator/pull/354) ([olleolleolle](https://github.com/olleolleolle))
**Closed issues:**
- Installation fails on Ubuntu [\#352](https://github.com/skywinder/github-changelog-generator/issues/352)
- Test installing on Windows: use AppVeyor [\#348](https://github.com/skywinder/github-changelog-generator/issues/348)
- Can't run under RubyGems 2.5.1 and Ruby 2.3.0 [\#325](https://github.com/skywinder/github-changelog-generator/issues/325)
- Ruby 2.3.0 - Deprecation warning: Github::ResponseWrapper\#respond\_to?\(:to\_ary\) is old fashion which takes only one parameter [\#323](https://github.com/skywinder/github-changelog-generator/issues/323)
- between-tags and exclude-tags do not work in .github\_changelog\_generator [\#317](https://github.com/skywinder/github-changelog-generator/issues/317)
- Add a "documentation" label [\#284](https://github.com/skywinder/github-changelog-generator/issues/284)
**Merged pull requests:**
- Replace shelling-out-to-Git w/ Dir call [\#360](https://github.com/skywinder/github-changelog-generator/pull/360) ([olleolleolle](https://github.com/olleolleolle))
- ParserFile: fail parsing with config file line number; use a File instead of a filename [\#357](https://github.com/skywinder/github-changelog-generator/pull/357) ([olleolleolle](https://github.com/olleolleolle))
- On gem install, do not try to copy manpage files in the "extensions" step [\#356](https://github.com/skywinder/github-changelog-generator/pull/356) ([olleolleolle](https://github.com/olleolleolle))
- Refactor: call it option\_name, instead of key\_sym [\#355](https://github.com/skywinder/github-changelog-generator/pull/355) ([olleolleolle](https://github.com/olleolleolle))
- Add a `bundle install` test [\#353](https://github.com/skywinder/github-changelog-generator/pull/353) ([jkeiser](https://github.com/jkeiser))
- Add an AppVeyor config [\#350](https://github.com/skywinder/github-changelog-generator/pull/350) ([Arcanemagus](https://github.com/Arcanemagus))
- README: Document GitHub token URI scope [\#345](https://github.com/skywinder/github-changelog-generator/pull/345) ([olleolleolle](https://github.com/olleolleolle))
## [1.11.7](https://github.com/skywinder/github-changelog-generator/tree/1.11.7) (2016-03-04)
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.6...1.11.7)

View File

@ -17,10 +17,10 @@ GEM
ast (2.2.0)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
codeclimate-test-reporter (0.4.8)
codeclimate-test-reporter (0.5.0)
simplecov (>= 0.7.1, < 1.0.0)
colorize (0.7.7)
coveralls (0.8.11)
coveralls (0.8.13)
json (~> 1.8)
simplecov (~> 0.11.0)
term-ansicolor (~> 1.3)
@ -61,12 +61,12 @@ GEM
powerpack (0.1.1)
rack (1.6.4)
rainbow (2.1.0)
rake (10.5.0)
rake (11.0.1)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.3)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
@ -75,12 +75,12 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.37.2)
parser (>= 2.3.0.4, < 3.0)
rubocop (0.38.0)
parser (>= 2.3.0.6, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 0.3)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.7.5)
simplecov (0.11.2)
docile (~> 1.1.0)
@ -92,7 +92,7 @@ GEM
thor (0.19.1)
thread_safe (0.3.5)
tins (1.6.0)
unicode-display_width (0.3.1)
unicode-display_width (1.0.1)
PLATFORMS
ruby

View File

@ -101,7 +101,7 @@ Therefore, it's recommended to run this script with authentication by using a **
Here's how:
- [Generate a token here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token)
- [Generate a token here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token) - you only need "repo" scope for private repositories
- Either:
- Run the script with `--token <your-40-digit-token>`; **OR**
- Set the `CHANGELOG_GITHUB_TOKEN` environment variable to your 40 digit token

50
appveyor.yml Normal file
View File

@ -0,0 +1,50 @@
version: "{build}"
platform: x64
branches:
only:
- master
clone_depth: 10
skip_tags: true
# See here for Ruby versions pre-installed:
# http://www.appveyor.com/docs/installed-software#ruby
environment:
matrix:
- ruby_version: "21" # Older version, but matches Travis-CI
- ruby_version: "21-x64"
install:
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
# Print version and location for pre-installed ruby
- ruby --version
- where ruby
# Install latest version of RubyGems
- gem update --system --no-document --no-post-install-message
- gem --version
- where gem
# Print version and location for pre-installed bundler
- bundler --version
- where bundler
build_script:
# Install ruby dependencies
- bundle install --retry 3
- bundle exec rake checks
test_script:
- gem build github_changelog_generator
- gem install *.gem
notifications:
- provider: Email
to:
- sky4winder+githubchangeloggenerator@gmail.com
on_build_success: false
on_build_status_changed: true

View File

@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
spec.description = "Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker."
spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
spec.license = "MIT"
spec.extensions = ["Rakefile"]
spec.files = `git ls-files -z`.split("\x0")
spec.files = Dir['{bin,lib,man,spec}/**/*', 'Rakefile', 'README.md']
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

View File

@ -3,34 +3,59 @@ require "pathname"
module GitHubChangelogGenerator
ParserError = Class.new(StandardError)
# ParserFile is a configuration file reader which sets options in the
# given Hash.
#
# In your project's root, you can put a file named
# <tt>.github_changelog_generator</tt> to override defaults.
#
# Example:
# header_label=# My Super Changelog
# ; Comments are allowed
# future-release=5.0.0
# # Ruby-style comments, too
# since-tag=1.0.0
#
# The configuration format is <tt>some-key=value</tt> or <tt>some_key=value</tt>.
#
class ParserFile
FILENAME = ".github_changelog_generator"
def initialize(options)
# @param options [Hash] options to be configured from file contents
# @param file [nil,IO] configuration file handle, defaults to opening `.github_changelog_generator`
def initialize(options, file = open_settings_file)
@options = options
@file = file
end
# Destructively change @options using data in configured options file.
# Sets options using configuration file content
def parse!
file.each_line { |line| parse_line!(line) } if file.exist?
return unless @file
@file.each_with_index { |line, i| parse_line!(line, i + 1) }
@file.close
end
private
def file
@file ||= Pathname(File.expand_path(@options[:params_file] || FILENAME))
FILENAME = ".github_changelog_generator"
def open_settings_file
path = Pathname(File.expand_path(FILENAME))
File.open(path) if path.exist?
end
def parse_line!(line)
key_sym, value = extract_pair(line)
value = true if value =~ /^(true|t|yes|y|1)$/i
value = false if value =~ /^(false|f|no|n|0)$/i
@options[key_sym] = value
def parse_line!(line, line_number)
return if non_configuration_line?(line)
option_name, value = extract_pair(line)
@options[option_key_for(option_name)] = convert_value(value, option_name)
rescue
raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
raise ParserError, "Failed on line ##{line_number}: \"#{line.gsub(/[\n\r]+/, '')}\""
end
# Returns a the setting as a symbol and its string value sans newlines.
# Returns true if the line starts with a pound sign or a semi-colon.
def non_configuration_line?(line)
line =~ /^[\#;]/ || line =~ /^[\s]+$/
end
# Returns a the option name as a symbol and its string value sans newlines.
#
# @param line [String] unparsed line from config file
# @return [Array<Symbol, String>]
@ -38,5 +63,41 @@ module GitHubChangelogGenerator
key, value = line.split("=", 2)
[key.sub("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end
KNOWN_ARRAY_KEYS = [:exclude_labels, :include_labels, :bug_labels,
:enhancement_labels, :between_tags, :exclude_tags]
KNOWN_INTEGER_KEYS = [:max_issues]
def convert_value(value, option_name)
if KNOWN_ARRAY_KEYS.include?(option_name)
value.split(",")
elsif KNOWN_INTEGER_KEYS.include?(option_name)
value.to_i
elsif value =~ /^(true|t|yes|y|1)$/i
true
elsif value =~ /^(false|f|no|n|0)$/i
false
else
value
end
end
IRREGULAR_OPTIONS = {
bugs_label: :bug_prefix,
enhancement_label: :enhancement_prefix,
issues_label: :issue_prefix,
header_label: :header,
front_matter: :frontmatter,
pr_label: :merge_prefix,
issues_wo_labels: :add_issues_wo_labels,
pr_wo_labels: :add_pr_wo_labels,
pull_requests: :pulls,
filter_by_milestone: :filter_issues_by_milestone,
github_api: :github_endpoint
}
def option_key_for(option_name)
IRREGULAR_OPTIONS.fetch(option_name) { option_name }
end
end
end

View File

@ -1 +0,0 @@
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90

View File

@ -1,2 +0,0 @@
unreleased_label: staging
unreleased: false

View File

@ -1,3 +0,0 @@
unreleased_label=staging
unreleased=false
header==== Changelog ===

View File

@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "github_changelog_generator", path: Dir.glob("../pkg/github_changelog_generator-*.gem")[0]

View File

@ -1,36 +1,47 @@
describe GitHubChangelogGenerator::ParserFile do
describe ".github_changelog_generator" do
context "when no has file" do
let(:options) { {} }
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
subject { parse.parse! }
let(:options) { {} }
context "when the well-known default file does not exist" do
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options) }
subject { parser.parse! }
it { is_expected.to be_nil }
end
context "when file is empty" do
let(:options) { { params_file: "spec/files/github_changelog_params_empty" } }
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, StringIO.new("")) }
it "does not change the options" do
expect { parse.parse! }.to_not change { options }
expect { parser.parse! }.to_not change { options }
end
end
context "when file is incorrect" do
let(:options) { { params_file: "spec/files/github_changelog_params_incorrect" } }
let(:options_before_change) { options.dup }
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
it { expect { parse.parse! }.to raise_error(GitHubChangelogGenerator::ParserError) }
let(:file) { StringIO.new("unreleased_label=staging\nunreleased: false") }
let(:parser) do
GitHubChangelogGenerator::ParserFile.new(options, file)
end
it { expect { parser.parse! }.to raise_error(/line #2/) }
end
context "allows empty lines and comments with semi-colon or pound sign" do
let(:file) { StringIO.new("\n \n# Comment on first line\nunreleased_label=staging\n; Comment on third line\nunreleased=false") }
let(:parser) do
GitHubChangelogGenerator::ParserFile.new(options, file)
end
it { expect { parser.parse! }.not_to raise_error }
end
context "when override default values" do
let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
let(:options) { { params_file: "spec/files/github_changelog_params_override" }.merge(default_options) }
let(:options) { {}.merge(default_options) }
let(:options_before_change) { options.dup }
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
let(:file) { StringIO.new("unreleased_label=staging\nunreleased=false\nheader==== Changelog ===") }
let(:parser) { GitHubChangelogGenerator::ParserFile.new(options, file) }
it "changes the options" do
expect { parse.parse! }.to change { options }
expect { parser.parse! }.to change { options }
.from(options_before_change)
.to(options_before_change.merge(unreleased_label: "staging",
unreleased: false,
@ -38,17 +49,24 @@ describe GitHubChangelogGenerator::ParserFile do
end
context "turns exclude-labels into an Array", bug: '#327' do
let(:options) do
{
params_file: "spec/files/github_changelog_params_327"
}
let(:file) do
StringIO.new(<<EOF
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
header_label=# My changelog
EOF
)
end
it "reads exclude_labels into an Array" do
pending("Related with Bug #327.")
expect { parse.parse! }.to change { options[:exclude_labels] }
.from(nil)
expect { parser.parse! }.to change { options[:exclude_labels] }
.from(default_options[:exclude_labels])
.to(["73a91042-da6f-11e5-9335-1040f38d7f90", "7adf83b4-da6f-11e5-ae18-1040f38d7f90"])
end
it "translates given header_label into the :header option" do
expect { parser.parse! }.to change { options[:header] }
.from(default_options[:header])
.to("# My changelog")
end
end
end
end