github_changelog_generator 1.15.2 → 1.16.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -6
  3. data/Rakefile +1 -1
  4. data/lib/github_changelog_generator/argv_parser.rb +225 -0
  5. data/lib/github_changelog_generator/generator/entry.rb +10 -10
  6. data/lib/github_changelog_generator/generator/generator.rb +41 -19
  7. data/lib/github_changelog_generator/generator/generator_fetcher.rb +5 -9
  8. data/lib/github_changelog_generator/generator/generator_processor.rb +23 -20
  9. data/lib/github_changelog_generator/generator/generator_tags.rb +15 -9
  10. data/lib/github_changelog_generator/generator/section.rb +27 -7
  11. data/lib/github_changelog_generator/helper.rb +1 -1
  12. data/lib/github_changelog_generator/octo_fetcher.rb +196 -149
  13. data/lib/github_changelog_generator/options.rb +4 -0
  14. data/lib/github_changelog_generator/parser.rb +70 -248
  15. data/lib/github_changelog_generator/parser_file.rb +29 -14
  16. data/lib/github_changelog_generator/reader.rb +4 -2
  17. data/lib/github_changelog_generator/ssl_certs/cacert.pem +851 -1756
  18. data/lib/github_changelog_generator/task.rb +3 -2
  19. data/lib/github_changelog_generator/version.rb +1 -1
  20. data/man/git-generate-changelog.1 +46 -34
  21. data/man/git-generate-changelog.1.html +39 -31
  22. data/man/git-generate-changelog.html +19 -19
  23. data/man/git-generate-changelog.md +39 -31
  24. data/spec/files/config_example +5 -0
  25. data/spec/spec_helper.rb +1 -1
  26. data/spec/unit/generator/entry_spec.rb +37 -31
  27. data/spec/unit/generator/generator_processor_spec.rb +99 -44
  28. data/spec/unit/generator/generator_spec.rb +47 -0
  29. data/spec/unit/generator/generator_tags_spec.rb +46 -3
  30. data/spec/unit/generator/section_spec.rb +34 -0
  31. data/spec/unit/octo_fetcher_spec.rb +45 -5
  32. data/spec/unit/parser_spec.rb +50 -0
  33. data/spec/unit/reader_spec.rb +9 -0
  34. metadata +44 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96d97ec2074cb54d75216a93b42f41a6216a418c1b0e926ab55a0cb9cb32a09b
4
- data.tar.gz: 75faf09151502f8f2d3cd4a15da37b26648ed504d42e3829ad95d1d7c71a9268
3
+ metadata.gz: 36cb65499e406ed1e554d4239e9d36806888d1ca9c3fe0f47e0e8e49053dd2b9
4
+ data.tar.gz: 991b1251d601d2504d2c610087b43d0deaebbe7f031987eda8dc5a84e7ac46cb
5
5
  SHA512:
6
- metadata.gz: 9f6adfd28ffcb632837a9d037b0677f6527b03d6a8c787ab9f65b2981b740e1bd478d0f0b64b76f8fab93d00d101b9b5fb80cb86ba7d722c98b0728534485cfc
7
- data.tar.gz: 81ee9e88cd5efa0c8acc60ce9f2a1571ea72fb9d9b096af07236477ff560e7561bd3eef31a3c9b26a5bdd6edba2656fe18b32509a7fbe8e40325f4974a94651a
6
+ metadata.gz: d5d733ce47da1d762b8dd3c4513989955ecd1adfe973ba044baef80fec2917d621841e9779d97b8298f04cd5b05d64c97d78cc872ba73d9b46ed2db3ae709344
7
+ data.tar.gz: ecfad19e0066fb2e9ddbdbc6c514f1c86bf57c6ff0704999adc05a181812fc182469ad77ba7d9fdabe1cbf06adff20680df06b0121c35e602c27222cab983106
data/README.md CHANGED
@@ -39,7 +39,7 @@ To update TOC, please run:
39
39
 
40
40
  ### Changelog generation has never been so easy
41
41
 
42
- **Fully automated changelog generation** - This gem generates a changelog file based on **tags**, **issues** and merged **pull requests** (and splits them into separate lists according to labels) from :octocat: GitHub Issue Tracker.
42
+ **Fully automated changelog generation** - This gem generates a changelog file based on **tags**, **issues** and merged **pull requests** (and splits them into separate lists according to labels) from :octocat: GitHub.
43
43
 
44
44
  Since you don't have to fill your `CHANGELOG.md` manually now: just run the script, relax and take a cup of :coffee: before your next release! :tada:
45
45
 
@@ -73,7 +73,9 @@ or use `sudo gem install github_changelog_generator` (Linux).
73
73
 
74
74
  ### Running with CLI:
75
75
 
76
- github_changelog_generator -u github_username -p github_project
76
+ github_changelog_generator -u github_project_namespace -p github_project
77
+
78
+ (where the project namespace is _likely_ your username if it's a project you own, but it could also be the namespace of the project)
77
79
 
78
80
 
79
81
  ### Running with Docker
@@ -82,11 +84,11 @@ Using [Docker](https://www.docker.com/products/docker-desktop) is an alternative
82
84
 
83
85
  Example invocation:
84
86
 
85
- $ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator
87
+ $ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator
86
88
 
87
89
 
88
90
 
89
- - For Github Enterprise repos, specify *both* `--github-site` and `--github-api` options:
91
+ - For GitHub Enterprise repos, specify *both* `--github-site` and `--github-api` options:
90
92
 
91
93
  $ github_changelog_generator --github-site="https://github.yoursite.com" \
92
94
  --github-api="https://github.yoursite.com/api/v3/"
@@ -318,7 +320,7 @@ Workaround: Create a `C:\tmp`.
318
320
 
319
321
  ## Contributing
320
322
 
321
- We have collected notes on how to contribute to this project in [CONTRIBUTING.md].
323
+ Would you like to contribute to this project? [CONTRIBUTING.md] has all the details on how to do that.
322
324
 
323
325
  [CONTRIBUTING.md]: CONTRIBUTING.md
324
326
 
@@ -327,4 +329,4 @@ We have collected notes on how to contribute to this project in [CONTRIBUTING.md
327
329
 
328
330
  ## License
329
331
 
330
- Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
332
+ GitHub Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ RSpec::Core::RakeTask.new
13
13
 
14
14
  desc "When releasing the gem, re-fetch latest cacert.pem from curl.haxx.se. Developer task."
15
15
  task :update_ssl_ca_file do
16
- `pushd lib/github_changelog_generator/ssl_certs && curl --remote-name --time-cond cacert.pem https://curl.haxx.se/ca/cacert.pem && popd`
16
+ `pushd lib/github_changelog_generator/ssl_certs && curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem && popd`
17
17
  end
18
18
 
19
19
  task default: %i[rubocop spec]
@@ -0,0 +1,225 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+ require "github_changelog_generator/version"
5
+
6
+ module GitHubChangelogGenerator
7
+ class ArgvParser
8
+ attr_reader :options
9
+
10
+ def initialize(options = {})
11
+ @options = options
12
+ end
13
+
14
+ def parse!(argv)
15
+ parser.parse(argv)
16
+ rescue OptionParser::ParseError => e
17
+ warn [e, parser].join("\n")
18
+ Kernel.abort
19
+ end
20
+
21
+ def parser
22
+ @parser ||= OptionParser.new do |opts| # rubocop:disable Metrics/BlockLength
23
+ opts.banner = "Usage: github_changelog_generator --user USER --project PROJECT [options]"
24
+ opts.on("-u", "--user USER", "Username of the owner of the target GitHub repo OR the namespace of target Github repo if owned by an organization.") do |last|
25
+ options[:user] = last
26
+ end
27
+ opts.on("-p", "--project PROJECT", "Name of project on GitHub.") do |last|
28
+ options[:project] = last
29
+ end
30
+ opts.on("-t", "--token TOKEN", "To make more than 50 requests per hour your GitHub token is required. You can generate it at: https://github.com/settings/tokens/new") do |last|
31
+ options[:token] = last
32
+ end
33
+ opts.on("-f", "--date-format FORMAT", "Date format. Default is %Y-%m-%d.") do |last|
34
+ options[:date_format] = last
35
+ end
36
+ opts.on("-o", "--output NAME", "Output file. To print to STDOUT instead, use blank as path. Default is CHANGELOG.md") do |last|
37
+ options[:output] = last
38
+ end
39
+ opts.on("-b", "--base NAME", "Optional base file to append generated changes to. Default is HISTORY.md") do |last|
40
+ options[:base] = last
41
+ end
42
+ opts.on("--summary-label LABEL", "Set up custom label for the release summary section. Default is \"\".") do |v|
43
+ options[:summary_prefix] = v
44
+ end
45
+ opts.on("--breaking-label LABEL", "Set up custom label for the breaking changes section. Default is \"**Breaking changes:**\".") do |v|
46
+ options[:breaking_prefix] = v
47
+ end
48
+ opts.on("--enhancement-label LABEL", "Set up custom label for enhancements section. Default is \"**Implemented enhancements:**\".") do |v|
49
+ options[:enhancement_prefix] = v
50
+ end
51
+ opts.on("--bugs-label LABEL", "Set up custom label for bug-fixes section. Default is \"**Fixed bugs:**\".") do |v|
52
+ options[:bug_prefix] = v
53
+ end
54
+ opts.on("--deprecated-label LABEL", "Set up custom label for the deprecated changes section. Default is \"**Deprecated:**\".") do |v|
55
+ options[:deprecated_prefix] = v
56
+ end
57
+ opts.on("--removed-label LABEL", "Set up custom label for the removed changes section. Default is \"**Removed:**\".") do |v|
58
+ options[:removed_prefix] = v
59
+ end
60
+ opts.on("--security-label LABEL", "Set up custom label for the security changes section. Default is \"**Security fixes:**\".") do |v|
61
+ options[:security_prefix] = v
62
+ end
63
+ opts.on("--issues-label LABEL", "Set up custom label for closed-issues section. Default is \"**Closed issues:**\".") do |v|
64
+ options[:issue_prefix] = v
65
+ end
66
+ opts.on("--header-label LABEL", "Set up custom header label. Default is \"# Changelog\".") do |v|
67
+ options[:header] = v
68
+ end
69
+ opts.on("--configure-sections HASH, STRING", "Define your own set of sections which overrides all default sections.") do |v|
70
+ options[:configure_sections] = v
71
+ end
72
+ opts.on("--add-sections HASH, STRING", "Add new sections but keep the default sections.") do |v|
73
+ options[:add_sections] = v
74
+ end
75
+ opts.on("--front-matter JSON", "Add YAML front matter. Formatted as JSON because it's easier to add on the command line.") do |v|
76
+ require "yaml"
77
+ options[:frontmatter] = "#{JSON.parse(v).to_yaml}---\n"
78
+ end
79
+ opts.on("--pr-label LABEL", "Set up custom label for pull requests section. Default is \"**Merged pull requests:**\".") do |v|
80
+ options[:merge_prefix] = v
81
+ end
82
+ opts.on("--[no-]issues", "Include closed issues in changelog. Default is true.") do |v|
83
+ options[:issues] = v
84
+ end
85
+ opts.on("--[no-]issues-wo-labels", "Include closed issues without labels in changelog. Default is true.") do |v|
86
+ options[:add_issues_wo_labels] = v
87
+ end
88
+ opts.on("--[no-]pr-wo-labels", "Include pull requests without labels in changelog. Default is true.") do |v|
89
+ options[:add_pr_wo_labels] = v
90
+ end
91
+ opts.on("--[no-]pull-requests", "Include pull-requests in changelog. Default is true.") do |v|
92
+ options[:pulls] = v
93
+ end
94
+ opts.on("--[no-]filter-by-milestone", "Use milestone to detect when issue was resolved. Default is true.") do |last|
95
+ options[:filter_issues_by_milestone] = last
96
+ end
97
+ opts.on("--[no-]issues-of-open-milestones", "Include issues of open milestones. Default is true.") do |v|
98
+ options[:issues_of_open_milestones] = v
99
+ end
100
+ opts.on("--[no-]author", "Add author of pull request at the end. Default is true.") do |author|
101
+ options[:author] = author
102
+ end
103
+ opts.on("--usernames-as-github-logins", "Use GitHub tags instead of Markdown links for the author of an issue or pull-request.") do |v|
104
+ options[:usernames_as_github_logins] = v
105
+ end
106
+ opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
107
+ options[:unreleased_only] = v
108
+ end
109
+ opts.on("--[no-]unreleased", "Add to log unreleased closed issues. Default is true.") do |v|
110
+ options[:unreleased] = v
111
+ end
112
+ opts.on("--unreleased-label LABEL", "Set up custom label for unreleased closed issues section. Default is \"**Unreleased:**\".") do |v|
113
+ options[:unreleased_label] = v
114
+ end
115
+ opts.on("--[no-]compare-link", "Include compare link (Full Changelog) between older version and newer version. Default is true.") do |v|
116
+ options[:compare_link] = v
117
+ end
118
+ opts.on("--include-labels x,y,z", Array, "Of the labeled issues, only include the ones with the specified labels.") do |list|
119
+ options[:include_labels] = list
120
+ end
121
+ opts.on("--exclude-labels x,y,z", Array, "Issues with the specified labels will be excluded from changelog. Default is 'duplicate,question,invalid,wontfix'.") do |list|
122
+ options[:exclude_labels] = list
123
+ end
124
+ opts.on("--summary-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Release Summary". The section display only body of issues. Default is \'release-summary,summary\'.') do |list|
125
+ options[:summary_labels] = list
126
+ end
127
+ opts.on("--breaking-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Breaking changes". Default is \'backwards-incompatible,breaking\'.') do |list|
128
+ options[:breaking_labels] = list
129
+ end
130
+ opts.on("--enhancement-labels x,y,z", Array, 'Issues with the specified labels will be added to "Implemented enhancements" section. Default is \'enhancement,Enhancement\'.') do |list|
131
+ options[:enhancement_labels] = list
132
+ end
133
+ opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be added to "Fixed bugs" section. Default is \'bug,Bug\'.') do |list|
134
+ options[:bug_labels] = list
135
+ end
136
+ opts.on("--deprecated-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Deprecated". Default is \'deprecated,Deprecated\'.') do |list|
137
+ options[:deprecated_labels] = list
138
+ end
139
+ opts.on("--removed-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Removed". Default is \'removed,Removed\'.') do |list|
140
+ options[:removed_labels] = list
141
+ end
142
+ opts.on("--security-labels x,y,z", Array, 'Issues with the specified labels will be added to a section called "Security fixes". Default is \'security,Security\'.') do |list|
143
+ options[:security_labels] = list
144
+ end
145
+ opts.on("--issue-line-labels x,y,z", Array, 'The specified labels will be shown in brackets next to each matching issue. Use "ALL" to show all labels. Default is [].') do |list|
146
+ options[:issue_line_labels] = list
147
+ end
148
+ opts.on("--include-tags-regex REGEX", "Apply a regular expression on tag names so that they can be included, for example: --include-tags-regex \".*\+\d{1,}\".") do |last|
149
+ options[:include_tags_regex] = last
150
+ end
151
+ opts.on("--exclude-tags x,y,z", Array, "Changelog will exclude specified tags") do |list|
152
+ options[:exclude_tags] = list
153
+ end
154
+ opts.on("--exclude-tags-regex REGEX", "Apply a regular expression on tag names so that they can be excluded, for example: --exclude-tags-regex \".*\+\d{1,}\".") do |last|
155
+ options[:exclude_tags_regex] = last
156
+ end
157
+ opts.on("--since-tag x", "Changelog will start after specified tag.") do |v|
158
+ options[:since_tag] = v
159
+ end
160
+ opts.on("--due-tag x", "Changelog will end before specified tag.") do |v|
161
+ options[:due_tag] = v
162
+ end
163
+ opts.on("--since-commit x", "Fetch only commits after this time. eg. \"2017-01-01 10:00:00\"") do |v|
164
+ options[:since_commit] = v
165
+ end
166
+ opts.on("--max-issues NUMBER", Integer, "Maximum number of issues to fetch from GitHub. Default is unlimited.") do |max|
167
+ options[:max_issues] = max
168
+ end
169
+ opts.on("--release-url URL", "The URL to point to for release links, in printf format (with the tag as variable).") do |url|
170
+ options[:release_url] = url
171
+ end
172
+ opts.on("--github-site URL", "The Enterprise GitHub site where your project is hosted.") do |last|
173
+ options[:github_site] = last
174
+ end
175
+ opts.on("--github-api URL", "The enterprise endpoint to use for your GitHub API.") do |last|
176
+ options[:github_endpoint] = last
177
+ end
178
+ opts.on("--simple-list", "Create a simple list from issues and pull requests. Default is false.") do |v|
179
+ options[:simple_list] = v
180
+ end
181
+ opts.on("--future-release RELEASE-VERSION", "Put the unreleased changes in the specified release number.") do |future_release|
182
+ options[:future_release] = future_release
183
+ end
184
+ opts.on("--release-branch RELEASE-BRANCH", "Limit pull requests to the release branch, such as master or release.") do |release_branch|
185
+ options[:release_branch] = release_branch
186
+ end
187
+ opts.on("--[no-]http-cache", "Use HTTP Cache to cache GitHub API requests (useful for large repos). Default is true.") do |http_cache|
188
+ options[:http_cache] = http_cache
189
+ end
190
+ opts.on("--cache-file CACHE-FILE", "Filename to use for cache. Default is github-changelog-http-cache in a temporary directory.") do |cache_file|
191
+ options[:cache_file] = cache_file
192
+ end
193
+ opts.on("--cache-log CACHE-LOG", "Filename to use for cache log. Default is github-changelog-logger.log in a temporary directory.") do |cache_log|
194
+ options[:cache_log] = cache_log
195
+ end
196
+ opts.on("--config-file CONFIG-FILE", "Path to configuration file. Default is .github_changelog_generator.") do |config_file|
197
+ options[:config_file] = config_file
198
+ end
199
+ opts.on("--ssl-ca-file PATH", "Path to cacert.pem file. Default is a bundled lib/github_changelog_generator/ssl_certs/cacert.pem. Respects SSL_CA_PATH.") do |ssl_ca_file|
200
+ options[:ssl_ca_file] = ssl_ca_file
201
+ end
202
+ opts.on("--require x,y,z", Array, "Path to Ruby file(s) to require before generating changelog.") do |paths|
203
+ options[:require] = paths
204
+ end
205
+ opts.on("--[no-]verbose", "Run verbosely. Default is true.") do |v|
206
+ options[:verbose] = v
207
+ end
208
+ opts.on("-v", "--version", "Print version number.") do |_v|
209
+ puts "Version: #{GitHubChangelogGenerator::VERSION}"
210
+ exit
211
+ end
212
+ opts.on("-h", "--help", "Displays Help.") do
213
+ puts opts
214
+ exit
215
+ end
216
+ end
217
+ end
218
+
219
+ class << self
220
+ def banner
221
+ new.parser.banner
222
+ end
223
+ end
224
+ end
225
+ end
@@ -40,6 +40,15 @@ module GitHubChangelogGenerator
40
40
  @content
41
41
  end
42
42
 
43
+ def line_labels_for(issue)
44
+ labels = if @options[:issue_line_labels] == ["ALL"]
45
+ issue["labels"]
46
+ else
47
+ issue["labels"].select { |label| @options[:issue_line_labels].include?(label["name"]) }
48
+ end
49
+ labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
50
+ end
51
+
43
52
  private
44
53
 
45
54
  # Creates section objects for this entry.
@@ -72,7 +81,7 @@ module GitHubChangelogGenerator
72
81
  end
73
82
 
74
83
  sections_json.collect do |name, v|
75
- Section.new(name: name.to_s, prefix: v["prefix"], labels: v["labels"], options: @options)
84
+ Section.new(name: name.to_s, prefix: v["prefix"], labels: v["labels"], body_only: v["body_only"], options: @options)
76
85
  end
77
86
  end
78
87
 
@@ -205,14 +214,5 @@ module GitHubChangelogGenerator
205
214
  end
206
215
  nil
207
216
  end
208
-
209
- def line_labels_for(issue)
210
- labels = if @options[:issue_line_labels] == ["ALL"]
211
- issue["labels"]
212
- else
213
- issue["labels"].select { |label| @options[:issue_line_labels].include?(label["name"]) }
214
- end
215
- labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
216
- end
217
217
  end
218
218
  end
@@ -26,6 +26,12 @@ module GitHubChangelogGenerator
26
26
  class Generator
27
27
  attr_accessor :options, :filtered_tags, :tag_section_mapping, :sorted_tags
28
28
 
29
+ CREDIT_LINE = <<~CREDIT
30
+ \\* *This Changelog was automatically generated \
31
+ by [github_changelog_generator]\
32
+ (https://github.com/github-changelog-generator/github-changelog-generator)*
33
+ CREDIT
34
+
29
35
  # A Generator responsible for all logic, related with changelog generation from ready-to-parse issues
30
36
  #
31
37
  # Example:
@@ -43,26 +49,21 @@ module GitHubChangelogGenerator
43
49
  # @return [String] Generated changelog file
44
50
  def compound_changelog
45
51
  @options.load_custom_ruby_files
46
- fetch_and_filter_tags
47
- fetch_issues_and_pr
48
-
49
- log = ""
50
- log += @options[:frontmatter] if @options[:frontmatter]
51
- log += "#{options[:header]}\n\n"
52
-
53
- log += if @options[:unreleased_only]
54
- generate_entry_between_tags(@filtered_tags[0], nil)
55
- else
56
- generate_entries_for_all_tags
57
- end
58
-
59
- log += File.read(@options[:base]) if File.file?(@options[:base])
60
-
61
- credit_line = "\n\n\\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*"
62
- log.gsub!(/#{credit_line}(\n)?/, "") # Remove old credit lines
63
- log += "#{credit_line}\n"
64
52
 
65
- @log = log
53
+ Sync do
54
+ fetch_and_filter_tags
55
+ fetch_issues_and_pr
56
+
57
+ log = if @options[:unreleased_only]
58
+ generate_entry_between_tags(@filtered_tags[0], nil)
59
+ else
60
+ generate_entries_for_all_tags
61
+ end
62
+ log += File.read(@options[:base]) if File.file?(@options[:base])
63
+ log = remove_old_fixed_string(log)
64
+ log = insert_fixed_string(log)
65
+ @log = log
66
+ end
66
67
  end
67
68
 
68
69
  private
@@ -151,5 +152,26 @@ module GitHubChangelogGenerator
151
152
  add_first_occurring_tag_to_prs(@sorted_tags, @pull_requests)
152
153
  nil
153
154
  end
155
+
156
+ # Remove the previously assigned fixed message.
157
+ # @param log [String] Old lines are fixed
158
+ def remove_old_fixed_string(log)
159
+ log.gsub!(/#{Regexp.escape(@options[:frontmatter])}/, "") if @options[:frontmatter]
160
+ log.gsub!(/#{Regexp.escape(@options[:header])}\n{,2}/, "")
161
+ log.gsub!(/\n{,2}#{Regexp.escape(CREDIT_LINE)}/, "") # Remove old credit lines
162
+ log
163
+ end
164
+
165
+ # Add template messages to given string. Previously added
166
+ # messages of the same wording are removed.
167
+ # @param log [String]
168
+ def insert_fixed_string(log)
169
+ ins = ""
170
+ ins += @options[:frontmatter] if @options[:frontmatter]
171
+ ins += "#{@options[:header]}\n\n"
172
+ log.insert(0, ins)
173
+ log += "\n\n#{CREDIT_LINE}"
174
+ log
175
+ end
154
176
  end
155
177
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  module GitHubChangelogGenerator
4
4
  class Generator
5
- MAX_THREAD_NUMBER = 25
6
-
7
5
  # Fetch event for issues and pull requests
8
6
  # @return [Array] array of fetched issues
9
7
  def fetch_events_for_issues_and_pr
@@ -64,7 +62,7 @@ module GitHubChangelogGenerator
64
62
  # @param [Array] prs The PRs to associate.
65
63
  # @return [Array] PRs without their merge_commit_sha in a tag.
66
64
  def associate_tagged_prs(tags, prs, total)
67
- @fetcher.fetch_tag_shas_async(tags)
65
+ @fetcher.fetch_tag_shas(tags)
68
66
 
69
67
  i = 0
70
68
  prs.reject do |pr|
@@ -106,7 +104,7 @@ module GitHubChangelogGenerator
106
104
  i = total - prs_left.count
107
105
  prs_left.reject do |pr|
108
106
  found = false
109
- if pr["events"] && (event = pr["events"].find { |e| e["event"] == "merged" }) && sha_in_release_branch(event["commit_id"])
107
+ if pr["events"] && (event = pr["events"].find { |e| e["event"] == "merged" }) && sha_in_release_branch?(event["commit_id"])
110
108
  found = true
111
109
  i += 1
112
110
  print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
@@ -139,7 +137,7 @@ module GitHubChangelogGenerator
139
137
  pr["first_occurring_tag"] = oldest_tag["name"]
140
138
  found = true
141
139
  i += 1
142
- elsif sha_in_release_branch(rebased_sha)
140
+ elsif sha_in_release_branch?(rebased_sha)
143
141
  found = true
144
142
  i += 1
145
143
  else
@@ -197,11 +195,9 @@ module GitHubChangelogGenerator
197
195
  #
198
196
  # @param [String] sha SHA to check.
199
197
  # @return [Boolean] True if SHA is in the branch git history.
200
- def sha_in_release_branch(sha)
198
+ def sha_in_release_branch?(sha)
201
199
  branch = @options[:release_branch] || @fetcher.default_branch
202
- commits_in_branch = @fetcher.fetch_compare(@fetcher.oldest_commit["sha"], branch)
203
- shas_in_branch = commits_in_branch["commits"].collect { |commit| commit["sha"] }
204
- shas_in_branch.include?(sha)
200
+ @fetcher.commits_in_branch(branch).include?(sha)
205
201
  end
206
202
  end
207
203
  end