lib/change_log.rb in urbanopt-cli-0.2.0.pre6 vs lib/change_log.rb in urbanopt-cli-0.2.0
- old
+ new
@@ -5,24 +5,26 @@
require 'optparse'
require 'optparse/date'
# Instructions:
# Get a token from github's settings (https://github.com/settings/tokens)
+# For security, set your token as an env variable. This script is prepared for one called GITHUB_CHANGELOG_TOKEN
#
# Example:
# ruby change_log.rb -t abcdefghijklmnopqrstuvwxyz -s 2017-09-06
#
options = {}
OptionParser.new do |opts|
- opts.banner = "Usage: change_log.rb [options]\n" +
- "Prints New, Open, Closed Issues, and number of accepted PRs"
- opts.separator ""
+ opts.banner = "Usage: change_log.rb [options]\n" \
+ 'Prints New, Open, Closed Issues, and number of accepted PRs'
+ opts.separator ''
# defaults, go back 90 days
options[:start_date] = Date.today - 90
- options[:end_date] = Date.today
+ # Add one day to end date to make it inclusive of current day.
+ options[:end_date] = Date.today + 1
opts.on('-s', '--start-date [DATE]', Date, 'Start of data (e.g. 2017-09-06)') do |v|
options[:start_date] = v
end
opts.on('-e', '--end-date [DATE]', Date, 'End of data (e.g. 2017-09-13)') do |v|
@@ -44,9 +46,12 @@
github = Github.new
if options[:token]
puts 'Using github token'
github = Github.new oauth_token: options[:token]
+elsif ENV['GITHUB_CHANGELOG_TOKEN']
+ puts 'Using Github token from user environment'
+ github = Github.new oauth_token: ENV['GITHUB_CHANGELOG_TOKEN']
end
total_open_issues = []
total_open_pull_requests = []
new_issues = []