support enterprise github via command line options
This commit is contained in:
parent
ad4c20d8d8
commit
6bad92e899
|
@ -28,12 +28,12 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
github_token
|
github_token
|
||||||
|
|
||||||
if @github_token.nil?
|
github_options = {per_page: PER_PAGE_NUMBER}
|
||||||
@github = Github.new per_page: PER_PAGE_NUMBER
|
github_options[:oauth_token] = @github_token unless @github_token.nil?
|
||||||
else
|
github_options[:endpoint] = options[:github_endpoint] unless options[:github_endpoint].nil?
|
||||||
@github = Github.new oauth_token: @github_token,
|
github_options[:site] = options[:github_endpoint] unless options[:github_site].nil?
|
||||||
per_page: PER_PAGE_NUMBER
|
|
||||||
end
|
@github = Github.new github_options
|
||||||
|
|
||||||
@generator = Generator.new(@options)
|
@generator = Generator.new(@options)
|
||||||
|
|
||||||
|
@ -276,8 +276,10 @@ module GitHubChangelogGenerator
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def create_log(pull_requests, issues, tag_name, tag_time)
|
def create_log(pull_requests, issues, tag_name, tag_time)
|
||||||
|
|
||||||
|
github_site = options[:github_site] || 'https://github.com'
|
||||||
|
|
||||||
# Generate tag name and link
|
# Generate tag name and link
|
||||||
log = "## [#{tag_name}] (https://github.com/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
|
log = "## [#{tag_name}] (#{github_site}/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
|
||||||
|
|
||||||
#Generate date string:
|
#Generate date string:
|
||||||
time_string = tag_time.strftime @options[:format]
|
time_string = tag_time.strftime @options[:format]
|
||||||
|
|
|
@ -46,6 +46,12 @@ module GitHubChangelogGenerator
|
||||||
opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list|
|
opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list|
|
||||||
options[:pull_request_labels] = list
|
options[:pull_request_labels] = list
|
||||||
end
|
end
|
||||||
|
opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last|
|
||||||
|
options[:github_site] = last
|
||||||
|
end
|
||||||
|
opts.on('--github-api [URL]', 'The enterprise endpoint to use for your Github API.') do |last|
|
||||||
|
options[:github_endpoint] = last
|
||||||
|
end
|
||||||
opts.on('-v', '--version', 'Print version number') do |v|
|
opts.on('-v', '--version', 'Print version number') do |v|
|
||||||
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
||||||
exit
|
exit
|
||||||
|
@ -59,8 +65,9 @@ module GitHubChangelogGenerator
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
if ARGV[0] && !ARGV[1]
|
if ARGV[0] && !ARGV[1]
|
||||||
|
github_site = options[:github_site] ? options[:github_site] : 'github.com'
|
||||||
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name
|
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name
|
||||||
match = /(?:.+github\.com\/)?(.+)\/(.+)/.match(ARGV[0])
|
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])
|
||||||
|
|
||||||
if match[2].nil?
|
if match[2].nil?
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in New Issue
Block a user