Remove repeated user and repo params

Used the github_options setting to add user and repo values
This commit is contained in:
Steve Gilvarry 2015-11-20 22:12:06 +11:00
parent 1d1965e7fb
commit afbb47ecf3

View File

@ -15,14 +15,13 @@ module GitHubChangelogGenerator
def initialize(options = {}) def initialize(options = {})
@options = options || {} @options = options || {}
@user = @options[:user]
@project = @options[:project]
@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[: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?
@release_branch = @options[:release_branch] unless @options[:release_branch].nil?
@github = check_github_response { Github.new github_options } @github = check_github_response { Github.new github_options }
end end
@ -66,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 @options[:user], @options[:project] response = @github.repos.tags
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|
@ -125,7 +124,9 @@ 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 @options[:user], @options[:project], state: "closed" response = @github.pull_requests.list @options[:user],
@options[:project],
state: "closed"
else else
response = @github.pull_requests.list @options[:user], @options[:project], state: "closed", base: @options[:release_branch] response = @github.pull_requests.list @options[:user], @options[:project], state: "closed", base: @options[:release_branch]
end end