From 9c6068f026fb14d6baa929a2bea635564fcffd20 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sat, 16 Apr 2016 23:20:36 +0200 Subject: [PATCH 01/10] Avoid nil bug in detect_since_tag --- .../generator/generator_tags.rb | 15 ++++---- spec/unit/generator/generator_tags_spec.rb | 37 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index fa0f40f..97e43b0 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -54,13 +54,14 @@ module GitHubChangelogGenerator # @return [Object] try to find newest tag using #Reader and :base option if specified otherwise returns nil def detect_since_tag - @since_tag ||= @options[:since_tag] - if @since_tag.nil? && @options[:base] && File.file?(@options[:base]) - reader = GitHubChangelogGenerator::Reader.new - content = reader.read(@options[:base]) - @since_tag = content[0]["version"] if content.count && content - end - @since_tag + @since_tag ||= @options.fetch(:since_tag) { version_of_first_item } + end + + def version_of_first_item + return unless File.file?(@options[:base].to_s) + + sections = GitHubChangelogGenerator::Reader.new.read(@options[:base]) + sections.first["version"] if sections && sections.any? end # Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index 04c9b50..c4aec07 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -206,7 +206,7 @@ describe GitHubChangelogGenerator::Generator do @generator.instance_variable_set :@fetcher, mock end subject do - of_tag = @generator.get_time_of_tag tag_mash_with_name("valid_tag") + of_tag = @generator.get_time_of_tag(tag_mash_with_name("valid_tag")) of_tag end it { is_expected.to be_a_kind_of(Time) } @@ -215,31 +215,32 @@ describe GitHubChangelogGenerator::Generator do end describe "#sort_tags_by_date" do - time1 = Time.now - time2 = Time.now - time3 = Time.now + let(:time1) { Time.now } + let(:time2) { Time.now } + let(:time3) { Time.now } + before(:all) do @generator = GitHubChangelogGenerator::Generator.new end + + before do + @generator.instance_variable_set(:@tag_times_hash, "valid_tag1" => time1, + "valid_tag2" => time2, + "valid_tag3" => time3) + end + + subject do + @generator.sort_tags_by_date(tags) + end context "sort unsorted tags" do - tags = tags_mash_from_strings %w(valid_tag1 valid_tag2 valid_tag3) - before do - @generator.instance_variable_set :@tag_times_hash, "valid_tag1" => time1, "valid_tag2" => time2, "valid_tag3" => time3 - end - subject do - @generator.sort_tags_by_date tags - end + let(:tags) { tags_mash_from_strings %w(valid_tag1 valid_tag2 valid_tag3) } + it { is_expected.to be_a_kind_of(Array) } it { is_expected.to match_array(tags.reverse!) } end context "sort sorted tags" do - tags = tags_mash_from_strings %w(valid_tag3 valid_tag2 valid_tag1) - before do - @generator.instance_variable_set :@tag_times_hash, "valid_tag1" => time1, "valid_tag2" => time2, "valid_tag3" => time3 - end - subject do - @generator.sort_tags_by_date tags - end + let(:tags) { tags_mash_from_strings %w(valid_tag3 valid_tag2 valid_tag1) } + it { is_expected.to be_a_kind_of(Array) } it { is_expected.to match_array(tags) } end From 86ca388ecff280f82d22c04c58ecd4323c65d243 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sun, 17 Apr 2016 00:06:54 +0200 Subject: [PATCH 02/10] Spec: Smaller help functions --- spec/unit/generator/generator_tags_spec.rb | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index c4aec07..057bb88 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -1,19 +1,14 @@ -def tag_mash_with_name(tag) - mash_tag = Hashie::Mash.new - mash_tag.name = tag - mash_tag -end - -def tags_mash_from_strings(tags_strings) - mash_array = [] - tags_strings.each do |tag| - mash_tag = tag_mash_with_name(tag) - mash_array << mash_tag - end - mash_array -end - describe GitHubChangelogGenerator::Generator do + def tag_mash_with_name(tag) + Hashie::Mash.new.tap {|mash_tag| mash_tag.name = tag } + end + + def tags_mash_from_strings(tags_strings) + tags_strings.map do |tag| + tag_mash_with_name(tag) + end + end + describe "#filter_between_tags" do context "when between_tags nil" do before do From 9ce5c76d4a6b8cc15cdcf255693936aead734807 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 18 Apr 2016 16:46:58 +0200 Subject: [PATCH 03/10] Linting --- spec/unit/generator/generator_tags_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index 057bb88..b837247 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -1,6 +1,6 @@ describe GitHubChangelogGenerator::Generator do def tag_mash_with_name(tag) - Hashie::Mash.new.tap {|mash_tag| mash_tag.name = tag } + Hashie::Mash.new.tap { |mash_tag| mash_tag.name = tag } end def tags_mash_from_strings(tags_strings) From cc653b6b21119d02ec1e66119663b7b11770c662 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Mon, 18 Apr 2016 16:53:45 +0200 Subject: [PATCH 04/10] linting --- spec/unit/generator/generator_tags_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index b837247..57fb8ba 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -100,13 +100,13 @@ describe GitHubChangelogGenerator::Generator do subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) } context "with matching regex" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[23]') } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") } it { is_expected.to be_a Array } it { is_expected.to match_array(tags_mash_from_strings(%w(1))) } end context "with non-matching regex" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[45]') } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") } it { is_expected.to be_a Array } it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) } end From 42dbedabb7d374f69b08d5b67ba545077db6696a Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sat, 30 Apr 2016 11:54:42 +0200 Subject: [PATCH 05/10] Add MIT LICENSE file This resolves #369. --- LICENSE | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f2823fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) +Copyright (c) 2016 Petr Korolev + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + From 8d4ab6c09c083ec6c31968baa17b41a507e2901d Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sat, 30 Apr 2016 12:03:15 +0200 Subject: [PATCH 06/10] Include LICENSE in distributed files --- github_changelog_generator.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github_changelog_generator.gemspec b/github_changelog_generator.gemspec index cb7ef0e..a3f53dc 100644 --- a/github_changelog_generator.gemspec +++ b/github_changelog_generator.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator" spec.license = "MIT" - spec.files = Dir["{bin,lib,man,spec}/**/*", "Rakefile", "README.md"] + spec.files = Dir["{bin,lib,man,spec}/**/*"] + %w(LICENSE Rakefile README.md) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) From ce87cecb4a2b68dab195d751329e5763894257a4 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 9 May 2016 14:43:59 +0300 Subject: [PATCH 07/10] This should fix #364 --- github_changelog_generator.gemspec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/github_changelog_generator.gemspec b/github_changelog_generator.gemspec index cb7ef0e..79f0be8 100644 --- a/github_changelog_generator.gemspec +++ b/github_changelog_generator.gemspec @@ -24,10 +24,11 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_runtime_dependency "rake", ">= 10.0" - spec.add_runtime_dependency "bundler", ">= 1.7" spec.add_runtime_dependency("github_api", ["~> 0.12"]) spec.add_runtime_dependency("colorize", ["~> 0.7"]) - spec.add_runtime_dependency("overcommit", ">= 0.31") - spec.add_runtime_dependency("rubocop", ">= 0.31") - spec.add_runtime_dependency("rspec", ">= 3.2") + + spec.add_development_dependency("overcommit", ">= 0.31") + spec.add_development_dependency("rspec", ">= 3.2") + spec.add_development_dependency "bundler", ">= 1.7" + spec.add_development_dependency("rubocop", ">= 0.31") end From 8722a309e6c94261122ec65c718fc068cf3b2347 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 9 May 2016 14:47:46 +0300 Subject: [PATCH 08/10] update gemfile --- Gemfile.lock | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fe0b9e9..18cbd94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,13 +2,9 @@ PATH remote: . specs: github_changelog_generator (1.12.0) - bundler (>= 1.7) colorize (~> 0.7) github_api (~> 0.12) - overcommit (>= 0.31) rake (>= 10.0) - rspec (>= 3.2) - rubocop (>= 0.31) GEM remote: https://rubygems.org/ @@ -40,11 +36,11 @@ GEM hashie (>= 3.4) multi_json (>= 1.7.5, < 2.0) oauth2 - hashie (3.4.3) + hashie (3.4.4) iniparse (1.4.2) json (1.8.3) jwt (1.5.1) - multi_json (1.11.2) + multi_json (1.12.0) multi_xml (0.5.5) multipart-post (2.0.0) oauth2 (1.1.0) @@ -53,15 +49,15 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - overcommit (0.32.0) + overcommit (0.33.0) childprocess (~> 0.5.8) iniparse (~> 1.4) - parser (2.3.0.6) + parser (2.3.1.0) ast (~> 2.2) powerpack (0.1.1) rack (1.6.4) rainbow (2.1.0) - rake (11.0.1) + rake (11.1.2) rspec (3.4.0) rspec-core (~> 3.4.0) rspec-expectations (~> 3.4.0) @@ -75,13 +71,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) + rubocop (0.39.0) + parser (>= 2.3.0.7, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) + ruby-progressbar (1.8.0) simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) @@ -92,7 +88,7 @@ GEM thor (0.19.1) thread_safe (0.3.5) tins (1.6.0) - unicode-display_width (1.0.1) + unicode-display_width (1.0.5) PLATFORMS ruby @@ -104,6 +100,7 @@ DEPENDENCIES github_changelog_generator! overcommit rake + rspec (>= 3.2) rubocop simplecov (~> 0.10) From 79f1b90ff839d3c403f44eaa772c70d9c07e119c Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 9 May 2016 15:08:09 +0300 Subject: [PATCH 09/10] fix rubocop checks --- spec/unit/generator/generator_tags_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/generator/generator_tags_spec.rb b/spec/unit/generator/generator_tags_spec.rb index 04c9b50..93876ec 100644 --- a/spec/unit/generator/generator_tags_spec.rb +++ b/spec/unit/generator/generator_tags_spec.rb @@ -105,13 +105,13 @@ describe GitHubChangelogGenerator::Generator do subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) } context "with matching regex" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[23]') } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[23]") } it { is_expected.to be_a Array } it { is_expected.to match_array(tags_mash_from_strings(%w(1))) } end context "with non-matching regex" do - let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[45]') } + let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: "[45]") } it { is_expected.to be_a Array } it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) } end From c2fd582c2d7ea95989fa2c7498cb2863b48c074e Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Mon, 9 May 2016 15:24:20 +0300 Subject: [PATCH 10/10] Update changelog for version 1.12.1 --- CHANGELOG.md | 14 ++++++++++++++ Gemfile.lock | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be8c8ff..a473be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## [1.12.1](https://github.com/skywinder/github-changelog-generator/tree/1.12.1) (2016-05-09) +[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.12.0...1.12.1) + +**Closed issues:** + +- Add a LICENSE file [\#369](https://github.com/skywinder/github-changelog-generator/issues/369) +- Error installing on Ubuntu 14.04 [\#364](https://github.com/skywinder/github-changelog-generator/issues/364) + +**Merged pull requests:** + +- Move dev gems to add\_development\_dependency [\#373](https://github.com/skywinder/github-changelog-generator/pull/373) ([skywinder](https://github.com/skywinder)) +- Add MIT LICENSE file [\#370](https://github.com/skywinder/github-changelog-generator/pull/370) ([olleolleolle](https://github.com/olleolleolle)) +- Avoid nil bug in detect\_since\_tag [\#368](https://github.com/skywinder/github-changelog-generator/pull/368) ([olleolleolle](https://github.com/olleolleolle)) + ## [1.12.0](https://github.com/skywinder/github-changelog-generator/tree/1.12.0) (2016-04-01) [Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.8...1.12.0) diff --git a/Gemfile.lock b/Gemfile.lock index 18cbd94..0cae2f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - github_changelog_generator (1.12.0) + github_changelog_generator (1.12.1) colorize (~> 0.7) github_api (~> 0.12) rake (>= 10.0) @@ -105,4 +105,4 @@ DEPENDENCIES simplecov (~> 0.10) BUNDLED WITH - 1.11.2 + 1.12.0.rc.2