Reinstate User and Repo options

Trying to use github options to hold repo and user didn’t seem to work
for all commands. Reverting those changes
This commit is contained in:
Steve Gilvarry 2016-01-03 07:02:19 +11:00
parent 01a0c05a02
commit 35b581240f

View File

@ -16,14 +16,14 @@ module GitHubChangelogGenerator
def initialize(options = {}) def initialize(options = {})
@options = options || {} @options = options || {}
@github_token = fetch_github_token @github_token = fetch_github_token
github_options = { per_page: PER_PAGE_NUMBER } @github_options = { per_page: PER_PAGE_NUMBER }
github_options[:user] = @options[:user] @github_options[:user] = @options[:user]
github_options[:repo] = @options[:project] @github_options[:repo] = @options[:project]
github_options[:oauth_token] = @github_token unless @github_token.nil? @github_options[:oauth_token] = @github_token unless @github_token.nil?
github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil? @github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil? @github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil?
@github = check_github_response { Github.new github_options } @github = check_github_response { Github.new @github_options }
end end
# Returns GitHub token. First try to use variable, provided by --token option, # Returns GitHub token. First try to use variable, provided by --token option,
@ -65,7 +65,7 @@ module GitHubChangelogGenerator
# @return [Array] array of tags in repo # @return [Array] array of tags in repo
def github_fetch_tags def github_fetch_tags
tags = [] tags = []
response = @github.repos.tags response = @github.repos.tags @options[:user], @options[:project]
page_i = 0 page_i = 0
count_pages = response.count_pages count_pages = response.count_pages
response.each_page do |page| response.each_page do |page|
@ -92,7 +92,9 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
issues = [] issues = []
begin begin
response = @github.issues.list state: "closed", response = @github.issues.list user: @options[:user],
repo: @options[:project],
state: "closed",
filter: "all", filter: "all",
labels: nil labels: nil
page_i = 0 page_i = 0
@ -122,9 +124,13 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
pull_requests = [] pull_requests = []
begin begin
if @options[:release_branch].nil? if @options[:release_branch].nil?
response = @github.pull_requests.list state: "closed" response = @github.pull_requests.list @options[:user],
@options[:project],
state: "closed"
else else
response = @github.pull_requests.list state: "closed", response = @github.pull_requests.list @options[:user],
@options[:project],
state: "closed",
base: @options[:release_branch] base: @options[:release_branch]
end end
page_i = 0 page_i = 0
@ -166,7 +172,9 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
issues_slice.each do |issue| issues_slice.each do |issue|
threads << Thread.new do threads << Thread.new do
begin begin
response = @github.issues.events.list issue_number: issue["number"] response = @github.issues.events.list user: @options[:user],
repo: @options[:project],
issue_number: issue["number"]
issue[:events] = [] issue[:events] = []
response.each_page do |page| response.each_page do |page|
issue[:events].concat(page) issue[:events].concat(page)
@ -193,8 +201,11 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
# @param [Hash] tag # @param [Hash] tag
# @return [Time] time of specified tag # @return [Time] time of specified tag
def fetch_date_of_tag(tag) def fetch_date_of_tag(tag)
puts @github_options
begin begin
commit_data = @github.git_data.commits.get tag["commit"]["sha"] commit_data = @github.git_data.commits.get @options[:user],
@options[:project],
tag["commit"]["sha"]
rescue rescue
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end
@ -205,7 +216,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
# Fetch commit for specified event # Fetch commit for specified event
# @return [Hash] # @return [Hash]
def fetch_commit(event) def fetch_commit(event)
@github.git_data.commits.get event[:commit_id] @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
end end
end end
end end