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
--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'
--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-api [URL] The enterprise endpoint to use for your Github API.
-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.
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
1. Create an issue to discuss about your idea

View File

@ -15,6 +15,8 @@ module GitHubChangelogGenerator
attr_accessor :options, :all_tags, :github
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
@ -27,10 +29,10 @@ module GitHubChangelogGenerator
github_options[:endpoint] = options[:github_endpoint] unless options[:github_endpoint].nil?
github_options[:site] = options[:github_endpoint] unless options[:github_site].nil?
begin
begin
@github = Github.new github_options
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
@generator = Generator.new(@options)
@ -92,10 +94,10 @@ rescue
issue[:actual_date] = issue[:closed_at]
else
begin
begin
begin
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
issue[:actual_date] = commit[:author][:date]
rescue
@ -119,7 +121,7 @@ rescue
print "Fetching merged dates...\r"
end
pull_requests = []
begin
begin
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
page_i = 0
response.each_page do |page|
@ -128,12 +130,10 @@ begin
print "Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
pull_requests.concat(page)
end
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
print " \r"
@pull_requests.each { |pr|
@ -290,11 +290,9 @@ rescue
end
def is_megred(number)
begin
@github.pull_requests.merged? @options[:user], @options[:project], number
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
end
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
def get_all_tags
@ -318,12 +316,10 @@ rescue
if @options[:verbose]
puts "Found #{tags.count} tags"
end
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
tags
end
@ -536,10 +532,10 @@ rescue
return @tag_times_hash[tag_name['name']]
end
begin
begin
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], tag_name['commit']['sha']
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
time_string = github_git_data_commits_get['committer']['date']
@tag_times_hash[tag_name['name']] = Time.parse(time_string)
@ -588,7 +584,7 @@ rescue
end
issues = []
begin
begin
response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
page_i = 0
count_pages = response.count_pages
@ -596,14 +592,12 @@ begin
page_i += PER_PAGE_NUMBER
print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
issues.concat(page)
break if issues.length >= @options[:max_issues]
break if @options[:max_issues] && issues.length >= @options[:max_issues]
end
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
print " \r"
if @options[:verbose]
@ -644,10 +638,10 @@ rescue
issues.each_slice(max_thread_number) { |issues_slice|
issues_slice.each { |issue|
threads << Thread.new {
begin
begin
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
rescue
puts "Warning: GitHub API rate limit exceed (5000 per hour), change log may not contain some issues.".yellow
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
issue[:events] = obj.body
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:**',
:author => true,
:filter_issues_by_milestone => true,
:max_issues => 500,
:max_issues => nil,
:compare_link => true,
:unreleased => true,
: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|
options[:exclude_labels] = list
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
end
opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last|