github_changelog_generator 1.13.0 → 1.13.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f9fa86c5ec84f94a0068a2cd3f44324a04de245
4
- data.tar.gz: e90426b204db5f28ab2b57eeb06c77742da6659a
3
+ metadata.gz: 8e430293bd753093d51737b3aaf29a26bae8ef4b
4
+ data.tar.gz: 364dbcfb8b20328bba88379a336aa45433eedc6b
5
5
  SHA512:
6
- metadata.gz: 17383504d020412e1f309da20187f0d2590b3a90308e8b0218e69d861f22976dbb895e7f9c1316154cc2d3a0c943e056ba405e16f6d821ef51970ce3d3b80eb5
7
- data.tar.gz: 3919d4f544aa5bf7ba5bfff2901bb34369ed5da4c0b715d90dee960915a0fd133fb6a7550cabf3e131dab3fac81c73c4ea8fc4ba25eb295b7c36e1e9c020c7e8
6
+ metadata.gz: 0521d48fb76e3c977ca363aae29ba92df2fd6b6784239b9c48c36ab06e3e72fe7e9ef942da314f46bb09322f8300beac8df7d55d7b83dabca7980dfbb1c4614d
7
+ data.tar.gz: 2bea3dbbe8ef1c41da35682c5234e00405a02cd44cc389d2d2a92b4e7f6b02f6b240a773aff9225393ffc5ef9d6ced71b279efd2dc03f8905c5f8187c01a4547
data/README.md CHANGED
@@ -77,6 +77,11 @@ Because software tools are for people. If you don’t care, why are you contribu
77
77
  - `github_changelog_generator -u github_username -p github_project`
78
78
  - `github_changelog_generator github_username/github_project`
79
79
 
80
+ - If you are running it against a repository on a Github Enterprise install, you must specify *both* `--github-site` and `--github-api` command line options:
81
+
82
+ github_changelog_generator --github-site="https://github.yoursite.com" \
83
+ --github-api="https://github.yoursite.com/api/v3/"
84
+
80
85
  This generates a changelog to the `CHANGELOG.md` file, with pretty markdown formatting.
81
86
 
82
87
  ### Params
@@ -133,6 +138,8 @@ we've provided a `rake` task library for your changelog generation.
133
138
  Just put something like this in your `Rakefile`:
134
139
 
135
140
  ```ruby
141
+ require 'github_changelog_generator/task'
142
+
136
143
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
137
144
  config.since_tag = '0.1.14'
138
145
  config.future_release = '0.2.0'
@@ -71,7 +71,7 @@ module GitHubChangelogGenerator
71
71
  response.each_page do |page|
72
72
  page_i += PER_PAGE_NUMBER
73
73
  print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
74
- tags.concat(page)
74
+ tags.concat(page) unless page.nil?
75
75
  end
76
76
  print_empty_line
77
77
 
@@ -160,7 +160,7 @@ module GitHubChangelogGenerator
160
160
  # Parse issue and generate single line formatted issue line.
161
161
  #
162
162
  # Example output:
163
- # - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) ([skywinder](https://github.com/skywinder))
163
+ # - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) (@skywinder)
164
164
  #
165
165
  # @param [Hash] issue Fetched issue from GitHub
166
166
  # @return [String] Markdown-formatted single issue
@@ -168,17 +168,22 @@ module GitHubChangelogGenerator
168
168
  encapsulated_title = encapsulate_string issue[:title]
169
169
 
170
170
  title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
171
+ issue_line_with_user(title_with_number, issue)
172
+ end
171
173
 
172
- unless issue.pull_request.nil?
173
- if @options[:author]
174
- title_with_number += if issue.user.nil?
175
- " ({Null user})"
176
- else
177
- " ([#{issue.user.login}](#{issue.user.html_url}))"
178
- end
179
- end
174
+ private
175
+
176
+ def issue_line_with_user(line, issue)
177
+ return line if !@options[:author] || issue.pull_request.nil?
178
+
179
+ user = issue.user
180
+ return "#{line} ({Null user})" unless user
181
+
182
+ if @options[:usernames_as_github_logins]
183
+ "#{line} (@#{user.login})"
184
+ else
185
+ "#{line} ([#{user.login}](#{user.html_url}))"
180
186
  end
181
- title_with_number
182
187
  end
183
188
  end
184
189
  end
@@ -23,7 +23,12 @@ module GitHubChangelogGenerator
23
23
  options
24
24
  end
25
25
 
26
- # @param [Hash] options to display
26
+ # If options set to verbose, print the parsed options.
27
+ #
28
+ # The GitHub `:token` key is censored in the output.
29
+ #
30
+ # @param options [Hash] The options to display
31
+ # @option options [Boolean] :verbose If false this method does nothing
27
32
  def self.print_options(options)
28
33
  if options[:verbose]
29
34
  Helper.log.info "Performing task with options:"
@@ -92,6 +97,9 @@ module GitHubChangelogGenerator
92
97
  opts.on("--[no-]author", "Add author of pull-request in the end. Default is true") do |author|
93
98
  options[:author] = author
94
99
  end
100
+ opts.on("--usernames-as-github-logins", "Use GitHub tags instead of Markdown links for the author of an issue or pull-request.") do |v|
101
+ options[:usernames_as_github_logins] = v
102
+ end
95
103
  opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
96
104
  options[:unreleased_only] = v
97
105
  end
@@ -167,7 +175,7 @@ module GitHubChangelogGenerator
167
175
  parser
168
176
  end
169
177
 
170
- # just get default options
178
+ # @return [Hash] Default options
171
179
  def self.default_options
172
180
  {
173
181
  tag1: nil,
@@ -199,13 +207,14 @@ module GitHubChangelogGenerator
199
207
  }
200
208
  end
201
209
 
210
+ # If `:user` or `:project` not set in options, try setting them
202
211
  def self.user_and_project_from_git(options)
203
212
  if options[:user].nil? || options[:project].nil?
204
213
  detect_user_and_project(options, ARGV[0], ARGV[1])
205
214
  end
206
215
  end
207
216
 
208
- # Detects user and project from git
217
+ # Sets `:user` and `:project` in `options` from CLI arguments or `git remote`
209
218
  def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
210
219
  options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
211
220
  return if options[:user] && options[:project]
@@ -219,16 +228,23 @@ module GitHubChangelogGenerator
219
228
  end
220
229
  end
221
230
 
222
- # Try to find user and project name from git remote output
231
+ # Returns GitHub username and project from CLI arguments
223
232
  #
224
- # @param [String] output of git remote command
225
- # @return [Array] user and project
233
+ # @param arg0 [String] This parameter takes two forms: Either a full
234
+ # GitHub URL, or a 'username/projectname', or
235
+ # simply a GitHub username
236
+ # @param arg1 [String] If arg0 is given as a username,
237
+ # then arg1 can given as a projectname
238
+ # @param github_site [String] Domain name of GitHub site
239
+ #
240
+ # @return [Array, nil] user and project, or nil if unsuccessful
226
241
  def self.user_project_from_option(arg0, arg1, github_site)
227
242
  user = nil
228
243
  project = nil
229
244
  github_site ||= "github.com"
230
245
  if arg0 && !arg1
231
- # this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
246
+ # this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or
247
+ # "skywinder/Github-Changelog-Generator" to user and name
232
248
  puts arg0
233
249
  match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(arg0)
234
250
 
@@ -248,35 +264,40 @@ module GitHubChangelogGenerator
248
264
  [user, project]
249
265
  end
250
266
 
251
- # Try to find user and project name from git remote output
267
+ # These patterns match these formats:
252
268
  #
253
- # @param [String] output of git remote command
254
- # @return [Array] user and project
255
- def self.user_project_from_remote(remote)
256
- # try to find repo in format:
257
- # origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
258
- # git@github.com:skywinder/Github-Changelog-Generator.git
259
- regex1 = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/
260
-
261
- # try to find repo in format:
262
- # origin https://github.com/skywinder/ChangelogMerger (fetch)
263
- # https://github.com/skywinder/ChangelogMerger
264
- regex2 = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/
265
-
266
- remote_structures = [regex1, regex2]
269
+ # ```
270
+ # origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
271
+ # git@github.com:skywinder/Github-Changelog-Generator.git
272
+ # ```
273
+ #
274
+ # and
275
+ #
276
+ # ```
277
+ # origin https://github.com/skywinder/ChangelogMerger (fetch)
278
+ # https://github.com/skywinder/ChangelogMerger
279
+ # ```
280
+ GIT_REMOTE_PATTERNS = [
281
+ /.*(?:[:\/])(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*)(?:\.git).*/,
282
+ /.*\/(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*).*/
283
+ ]
267
284
 
285
+ # Returns GitHub username and project from git remote output
286
+ #
287
+ # @param git_remote_output [String] Output of git remote command
288
+ #
289
+ # @return [Array] user and project
290
+ def self.user_project_from_remote(git_remote_output)
268
291
  user = nil
269
292
  project = nil
270
- remote_structures.each do |regex|
271
- matches = Regexp.new(regex).match(remote)
293
+ GIT_REMOTE_PATTERNS.each do |git_remote_pattern|
294
+ git_remote_pattern =~ git_remote_output
272
295
 
273
- if matches && matches[1] && matches[2]
274
- puts "Detected user:#{matches[1]}, project:#{matches[2]}"
275
- user = matches[1]
276
- project = matches[2]
296
+ if Regexp.last_match
297
+ user = Regexp.last_match(:user)
298
+ project = Regexp.last_match(:project)
299
+ break
277
300
  end
278
-
279
- break unless matches.nil?
280
301
  end
281
302
 
282
303
  [user, project]
@@ -14,7 +14,7 @@ module GitHubChangelogGenerator
14
14
  unreleased_only unreleased unreleased_label
15
15
  compare_link include_labels exclude_labels
16
16
  bug_labels enhancement_labels
17
- between_tags exclude_tags since_tag max_issues
17
+ between_tags exclude_tags exclude_tags_regex since_tag max_issues
18
18
  github_site github_endpoint simple_list
19
19
  future_release release_branch verbose release_url
20
20
  base )
@@ -1,3 +1,3 @@
1
1
  module GitHubChangelogGenerator
2
- VERSION = "1.13.0"
2
+ VERSION = "1.13.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_changelog_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Korolev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-04 00:00:00.000000000 Z
12
+ date: 2016-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake