px_github_changelog_generator 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +9 -0
  3. data/README.md +357 -0
  4. data/Rakefile +19 -0
  5. data/bin/git-generate-changelog +5 -0
  6. data/bin/github_changelog_generator +5 -0
  7. data/lib/github_changelog_generator/argv_parser.rb +225 -0
  8. data/lib/github_changelog_generator/file_parser_chooser.rb +27 -0
  9. data/lib/github_changelog_generator/generator/entry.rb +218 -0
  10. data/lib/github_changelog_generator/generator/generator.rb +177 -0
  11. data/lib/github_changelog_generator/generator/generator_fetcher.rb +202 -0
  12. data/lib/github_changelog_generator/generator/generator_processor.rb +237 -0
  13. data/lib/github_changelog_generator/generator/generator_tags.rb +210 -0
  14. data/lib/github_changelog_generator/generator/section.rb +129 -0
  15. data/lib/github_changelog_generator/helper.rb +37 -0
  16. data/lib/github_changelog_generator/octo_fetcher.rb +535 -0
  17. data/lib/github_changelog_generator/options.rb +159 -0
  18. data/lib/github_changelog_generator/parser.rb +89 -0
  19. data/lib/github_changelog_generator/parser_file.rb +101 -0
  20. data/lib/github_changelog_generator/reader.rb +88 -0
  21. data/lib/github_changelog_generator/ssl_certs/cacert.pem +3138 -0
  22. data/lib/github_changelog_generator/task.rb +68 -0
  23. data/lib/github_changelog_generator/version.rb +5 -0
  24. data/lib/github_changelog_generator.rb +49 -0
  25. data/man/git-generate-changelog.1 +393 -0
  26. data/man/git-generate-changelog.1.html +359 -0
  27. data/man/git-generate-changelog.html +270 -0
  28. data/man/git-generate-changelog.md +274 -0
  29. data/spec/files/angular.js.md +9395 -0
  30. data/spec/files/bundler.md +1911 -0
  31. data/spec/files/config_example +5 -0
  32. data/spec/files/github-changelog-generator.md +305 -0
  33. data/spec/github_changelog_generator_spec.rb +32 -0
  34. data/spec/install_gem_in_bundler.gemfile +5 -0
  35. data/spec/spec_helper.rb +74 -0
  36. data/spec/unit/generator/entry_spec.rb +766 -0
  37. data/spec/unit/generator/generator_processor_spec.rb +203 -0
  38. data/spec/unit/generator/generator_spec.rb +47 -0
  39. data/spec/unit/generator/generator_tags_spec.rb +337 -0
  40. data/spec/unit/generator/section_spec.rb +43 -0
  41. data/spec/unit/octo_fetcher_spec.rb +590 -0
  42. data/spec/unit/options_spec.rb +67 -0
  43. data/spec/unit/parser_file_spec.rb +94 -0
  44. data/spec/unit/parser_spec.rb +54 -0
  45. data/spec/unit/reader_spec.rb +120 -0
  46. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits/when_API_is_valid/returns_commits.json +1 -0
  47. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_commits_before/when_API_is_valid/returns_commits.json +1 -0
  48. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issue_with_proper_key/values.json +1 -0
  49. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues.json +1 -0
  50. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_issues_with_labels.json +1 -0
  51. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_request_with_proper_key/values.json +1 -0
  52. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid/returns_pull_requests_with_labels.json +1 -0
  53. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_issues_and_pr/when_API_call_is_valid.json +1 -0
  54. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_correct_pull_request_keys.json +1 -0
  55. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid/returns_pull_requests.json +1 -0
  56. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_closed_pull_requests/when_API_call_is_valid.json +1 -0
  57. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid/returns_commit.json +1 -0
  58. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_commit/when_API_call_is_valid.json +1 -0
  59. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid/returns_date.json +1 -0
  60. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_date_of_tag/when_API_call_is_valid.json +1 -0
  61. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid/populates_issues.json +1 -0
  62. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_fetch_events_async/when_API_call_is_valid.json +1 -0
  63. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags.json +1 -0
  64. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid/should_return_tags_count.json +1 -0
  65. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_API_call_is_valid.json +1 -0
  66. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided/should_raise_Unauthorized_error.json +1 -0
  67. data/spec/vcr/GitHubChangelogGenerator_OctoFetcher/_github_fetch_tags/when_wrong_token_provided.json +1 -0
  68. metadata +250 -0
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GitHubChangelogGenerator::ParserFile do
4
+ describe ".github_changelog_generator" do
5
+ let(:options) { {} }
6
+ let(:parser) { described_class.new(options, StringIO.new(file)) }
7
+
8
+ context "when the well-known default file does not exist" do
9
+ let(:parser) { described_class.new(options) }
10
+
11
+ subject { parser.parse! }
12
+
13
+ it { is_expected.to be_nil }
14
+ end
15
+
16
+ context "when file is empty" do
17
+ let(:file) { "" }
18
+
19
+ it "does not change the options" do
20
+ expect { parser.parse! }.to_not(change { options })
21
+ end
22
+ end
23
+
24
+ context "when file is incorrect" do
25
+ let(:file) do
26
+ <<~FILE.strip
27
+ unreleased_label=staging
28
+ unreleased: false
29
+ FILE
30
+ end
31
+
32
+ it { expect { parser.parse! }.to raise_error(/line #2/) }
33
+ end
34
+
35
+ context "allows empty lines and comments with semi-colon or pound sign" do
36
+ let(:file) do
37
+ "\n \n#{<<~REMAINING.strip}"
38
+ # Comment on first line
39
+ unreleased_label=staging
40
+ ; Comment on third line
41
+ unreleased=false
42
+ REMAINING
43
+ end
44
+
45
+ it { expect { parser.parse! }.not_to raise_error }
46
+ end
47
+
48
+ context "when override default values" do
49
+ let(:default_options) { GitHubChangelogGenerator::Parser.default_options.merge(verbose: false) }
50
+ let(:options) { {}.merge(default_options) }
51
+ let(:options_before_change) { options.dup }
52
+ let(:file) do
53
+ <<~FILE.strip
54
+ unreleased_label=staging
55
+ unreleased=false
56
+ header==== Changelog ===
57
+ max_issues=123
58
+ simple-list=true
59
+ FILE
60
+ end
61
+
62
+ it "changes the options" do
63
+ expect { parser.parse! }.to change { options }
64
+ .from(options_before_change)
65
+ .to(options_before_change.merge(unreleased_label: "staging",
66
+ unreleased: false,
67
+ header: "=== Changelog ===",
68
+ max_issues: 123,
69
+ simple_list: true))
70
+ end
71
+
72
+ context "turns exclude-labels into an Array", bug: "#327" do
73
+ let(:file) do
74
+ <<~FILE
75
+ exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
76
+ header_label=# My changelog
77
+ FILE
78
+ end
79
+
80
+ it "reads exclude_labels into an Array" do
81
+ expect { parser.parse! }.to change { options[:exclude_labels] }
82
+ .from(default_options[:exclude_labels])
83
+ .to(%w[73a91042-da6f-11e5-9335-1040f38d7f90 7adf83b4-da6f-11e5-ae18-1040f38d7f90])
84
+ end
85
+
86
+ it "translates given header_label into the :header option" do
87
+ expect { parser.parse! }.to change { options[:header] }
88
+ .from(default_options[:header])
89
+ .to("# My changelog")
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GitHubChangelogGenerator::Parser do
4
+ let(:argv) { [] }
5
+
6
+ before do
7
+ # Calling abort will abort the test run, allow calls to abort to not accidentaly get positive falses
8
+ allow(Kernel).to receive(:abort)
9
+ end
10
+
11
+ describe ".parse_options" do
12
+ context "when required arguments are given" do
13
+ let(:argv) { ["--user", "the user", "--project", "the_project"] }
14
+
15
+ it "executes and prints the configuration" do
16
+ expect { described_class.parse_options(argv) }.to output(/config_file=>".github_changelog_generator"/).to_stdout
17
+ end
18
+ end
19
+
20
+ context "when --config-file is overridden to something that is not there" do
21
+ let(:argv) { ["--config-file", "does_not_exist"] }
22
+
23
+ it "aborts the execution" do
24
+ expect(Kernel).to receive(:abort)
25
+ expect { described_class.parse_options(argv) }.to output(/Configure which user and project to work on./).to_stderr
26
+ end
27
+ end
28
+
29
+ context "when an option with incorrect type is given" do
30
+ let(:argv) { ["--max-issues", "X"] }
31
+
32
+ it "aborts the execution with error message from parser" do
33
+ expect(Kernel).to receive(:abort)
34
+ expect { described_class.parse_options(argv) }.to output(/invalid argument: --max-issues X/).to_stderr
35
+ end
36
+ end
37
+
38
+ context "when path to configuration file is given" do
39
+ let(:argv) { ["--config-file", File.join(__dir__, "..", "files", "config_example")] }
40
+
41
+ it "uses the values from the configuration file" do
42
+ expect { described_class.parse_options(argv) }.to output(/spec_project/).to_stdout
43
+ end
44
+ end
45
+
46
+ context "when configuration file and parameters are given" do
47
+ let(:argv) { ["--project", "stronger_project", "--config-file", File.join(__dir__, "..", "files", "config_example")] }
48
+
49
+ it "uses the values from the arguments" do
50
+ expect { described_class.parse_options(argv) }.to output(/stronger_project/).to_stdout
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Author:: Enrico Stahn <mail@enricostahn.com>
5
+ #
6
+ # Copyright 2014, Zanui, <engineering@zanui.com.au>
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ describe GitHubChangelogGenerator::Reader do
22
+ before(:all) do
23
+ @reader = GitHubChangelogGenerator::Reader.new
24
+ end
25
+
26
+ describe "#parse_heading" do
27
+ context "when heading is empty" do
28
+ subject { @reader.parse_heading("## ") }
29
+ it { is_expected.to be_a(Hash) }
30
+ it { is_expected.to include("version", "url", "date") }
31
+ it { is_expected.to include("version" => nil, "url" => nil, "date" => nil) }
32
+ # TODO: Doesn't work?
33
+ # it { is_expected.to have_all_string_keys }
34
+ end
35
+ context "when given version, url and date" do
36
+ subject { @reader.parse_heading("## [1.3.10](https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10) (2015-03-18)") }
37
+ it { is_expected.to include("version" => "1.3.10") }
38
+ it { is_expected.to include("url" => "https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10") }
39
+ it { is_expected.to include("date" => "2015-03-18") }
40
+ end
41
+ context "when given a named link" do
42
+ subject { @reader.parse_heading("## [1.3.10]") }
43
+ it { is_expected.to include("version" => "1.3.10") }
44
+ end
45
+ context "when given a named link with date" do
46
+ subject { @reader.parse_heading("## [1.3.10] (2015-03-18)") }
47
+ it { is_expected.to include("version" => "1.3.10") }
48
+ it { is_expected.to include("date" => "2015-03-18") }
49
+ end
50
+ context "when no url and date is provided" do
51
+ subject { @reader.parse_heading("## foobar") }
52
+ it { is_expected.to include("version" => "foobar", "url" => nil, "date" => nil) }
53
+ end
54
+ end
55
+
56
+ describe "#parse" do
57
+ context "when file is empty" do
58
+ subject { @reader.parse("") }
59
+ it { is_expected.to be_an(Array) }
60
+ it { is_expected.to be_empty }
61
+ end
62
+ context "when file has only the header" do
63
+ subject { @reader.parse("# Changelog") }
64
+ it { is_expected.to be_an(Array) }
65
+ it { is_expected.to be_empty }
66
+ end
67
+ end
68
+
69
+ describe "example CHANGELOG files" do
70
+ subject { @reader.read(File.expand_path(File.join(File.dirname(__FILE__), "..", "files", self.class.description))) }
71
+ context "github-changelog-generator.md" do
72
+ it { is_expected.to be_an(Array) }
73
+ it { is_expected.not_to be_empty }
74
+ it { expect(subject.count).to eq(28) }
75
+ it { expect(subject.first).to include("version" => "1.3.10") }
76
+ it { expect(subject.first).to include("url" => "https://github.com/github-changelog-generator/Github-Changelog-Generator/tree/1.3.10") }
77
+ it { expect(subject.first).to include("date" => "2015-03-18") }
78
+ it { expect(subject.first).to include("content") }
79
+ it "content should not be empty" do
80
+ expect(subject.first["content"]).not_to be_empty
81
+ end
82
+ end
83
+ context "bundler.md" do
84
+ it { is_expected.to be_an(Array) }
85
+ it { is_expected.not_to be_empty }
86
+ it { expect(subject.count).to eq(151) }
87
+ it { expect(subject.first).to include("version" => "1.9.1") }
88
+ it { expect(subject.first).to include("url" => nil) }
89
+ it { expect(subject.first).to include("date" => "2015-03-21") }
90
+ it { expect(subject.first).to include("content") }
91
+ it "content should not be empty" do
92
+ expect(subject.first["content"]).not_to be_empty
93
+ end
94
+ end
95
+ context "angular.js.md" do
96
+ it { is_expected.to be_an(Array) }
97
+ it { is_expected.not_to be_empty }
98
+ # it do
99
+ # pending('Implement heading_level for parser.')
100
+ # expect(subject.first).to include('version' => '1.4.0-beta.6 cookie-liberation')
101
+ # end
102
+ # it do
103
+ # pending('Implement heading_level for parser.')
104
+ # expect(subject.first).to include('url' => nil)
105
+ # end
106
+ # it do
107
+ # pending('Implement heading_level for parser.')
108
+ # expect(subject.first).to include('date' => '2015-03-17')
109
+ # end
110
+ # it do
111
+ # pending('Implement heading_level for parser.')
112
+ # expect(subject.first).to include('content')
113
+ # end
114
+ # it 'content should not be empty' do
115
+ # pending('Implement heading_level for parser.')
116
+ # expect(subject.first['content']).not_to be_empty
117
+ # end
118
+ end
119
+ end
120
+ end