Improved --max-issues docs and messaging

- defaulted max issues to be unlimited in number allowing user to optionally limit issues returned
- added FAQ section on rate limiting and API rate limit exceeded warning
This commit is contained in:
Shawn Neal 2015-03-23 08:13:44 -07:00 committed by Petr Korolev
parent 90f6436af6
commit 1456ba8913
3 changed files with 77 additions and 74 deletions

View File

@ -96,7 +96,7 @@ Type `github_changelog_generator --help` for detailed usage.
--[no-]compare-link Include compare link between older version and newer version. Default is true --[no-]compare-link Include compare link between older version and newer version. Default is true
--include-labels x,y,z Issues only with that labels will be included to changelog. Default is 'bug,enhancement' --include-labels x,y,z Issues only with that labels will be included to changelog. Default is 'bug,enhancement'
--exclude-labels x,y,z Issues with that labels will be always excluded from changelog. Default is 'duplicate,question,invalid,wontfix' --exclude-labels x,y,z Issues with that labels will be always excluded from changelog. Default is 'duplicate,question,invalid,wontfix'
--max-issues [NUMBER] Max number of issues to fetch from GitHub. Default is 500. --max-issues [NUMBER] Max number of issues to fetch from GitHub. Default is unlimited.
--github-site [URL] The Enterprise Github site on which your project is hosted. --github-site [URL] The Enterprise Github site on which your project is hosted.
--github-api [URL] The enterprise endpoint to use for your Github API. --github-api [URL] The enterprise endpoint to use for your Github API.
-v, --version Print version number -v, --version Print version number
@ -187,6 +187,15 @@ I think, that GitHub Releases is more for end-users.
But `CHANGELOG.md` could stay in the repo for developers with detailed list of changes. But `CHANGELOG.md` could stay in the repo for developers with detailed list of changes.
And it's nothing bad to combine GitHub Releases and `CHANGELOG.md` file together in that manner. And it's nothing bad to combine GitHub Releases and `CHANGELOG.md` file together in that manner.
- ***I received a warning: GitHub API rate limit exceed, what does this mean?***
GitHub [limits the number of API requests](https://developer.github.com/v3/#rate-limiting) you can make in an hour. You can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour. Unauthenticated requests are associated with your IP address, and not the user making requests.
If you're seeing this warning:
1. Make sure you're providing an OAuth token so you're not anonymously making requests. This will increase the number of requests from 60 to 5000 per hour.
2. You probably have a large repo with lots of issues/PRs. You can use the `--max-issues NUM` argument to limit the number of issues that are pulled back. For example: `--max-issues 1000`
## Contributing ## Contributing
1. Create an issue to discuss about your idea 1. Create an issue to discuss about your idea

View File

@ -15,6 +15,8 @@ module GitHubChangelogGenerator
attr_accessor :options, :all_tags, :github attr_accessor :options, :all_tags, :github
PER_PAGE_NUMBER = 30 PER_PAGE_NUMBER = 30
GH_RATE_LIMIT_EXCEEDED_MSG = 'Warning: GitHub API rate limit exceed (5000 per hour), change log may not ' +
'contain some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument'
def initialize def initialize
@ -30,7 +32,7 @@ module GitHubChangelogGenerator
begin begin
@github = Github.new github_options @github = Github.new github_options
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
@generator = Generator.new(@options) @generator = Generator.new(@options)
@ -95,7 +97,7 @@ rescue
begin begin
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id] commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
issue[:actual_date] = commit[:author][:date] issue[:actual_date] = commit[:author][:date]
rescue rescue
@ -129,11 +131,9 @@ begin
pull_requests.concat(page) pull_requests.concat(page)
end end
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
print " \r" print " \r"
@pull_requests.each { |pr| @pull_requests.each { |pr|
@ -290,11 +290,9 @@ rescue
end end
def is_megred(number) def is_megred(number)
begin
@github.pull_requests.merged? @options[:user], @options[:project], number @github.pull_requests.merged? @options[:user], @options[:project], number
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
end end
def get_all_tags def get_all_tags
@ -319,11 +317,9 @@ rescue
puts "Found #{tags.count} tags" puts "Found #{tags.count} tags"
end end
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
tags tags
end end
@ -539,7 +535,7 @@ rescue
begin begin
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], tag_name['commit']['sha'] github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], tag_name['commit']['sha']
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
time_string = github_git_data_commits_get['committer']['date'] time_string = github_git_data_commits_get['committer']['date']
@tag_times_hash[tag_name['name']] = Time.parse(time_string) @tag_times_hash[tag_name['name']] = Time.parse(time_string)
@ -596,14 +592,12 @@ begin
page_i += PER_PAGE_NUMBER page_i += PER_PAGE_NUMBER
print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
issues.concat(page) issues.concat(page)
break if issues.length >= @options[:max_issues] break if @options[:max_issues] && issues.length >= @options[:max_issues]
end end
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
print " \r" print " \r"
if @options[:verbose] if @options[:verbose]
@ -647,7 +641,7 @@ rescue
begin begin
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number'] obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
rescue rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
issue[:events] = obj.body issue[:events] = obj.body
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r" print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"

View File

@ -24,7 +24,7 @@ module GitHubChangelogGenerator
:enhancement_prefix => '**Implemented enhancements:**', :enhancement_prefix => '**Implemented enhancements:**',
:author => true, :author => true,
:filter_issues_by_milestone => true, :filter_issues_by_milestone => true,
:max_issues => 500, :max_issues => nil,
:compare_link => true, :compare_link => true,
:unreleased => true, :unreleased => true,
:unreleased_label => 'Unreleased', :unreleased_label => 'Unreleased',
@ -84,7 +84,7 @@ module GitHubChangelogGenerator
opts.on('--exclude-labels x,y,z', Array, 'Issues with that labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list| opts.on('--exclude-labels x,y,z', Array, 'Issues with that labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
options[:exclude_labels] = list options[:exclude_labels] = list
end end
opts.on('--max-issues [NUMBER]', Integer, 'Max number of issues to fetch from GitHub. Default is 500') do |max| opts.on('--max-issues [NUMBER]', Integer, 'Max number of issues to fetch from GitHub. Default is unlimited') do |max|
options[:max_issues] = max options[:max_issues] = max
end end
opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last| opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last|