Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/github_changelog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def initialize

github_token

if @github_token.nil?
@github = Github.new per_page: PER_PAGE_NUMBER
else
@github = Github.new oauth_token: @github_token,
per_page: PER_PAGE_NUMBER
end
github_options = {per_page: PER_PAGE_NUMBER}
github_options[:oauth_token] = @github_token unless @github_token.nil?
github_options[:endpoint] = options[:github_endpoint] unless options[:github_endpoint].nil?
github_options[:site] = options[:github_endpoint] unless options[:github_site].nil?

@github = Github.new github_options

@generator = Generator.new(@options)

Expand Down Expand Up @@ -276,8 +276,10 @@ def delete_by_time(array, hash_key, newer_tag_time, older_tag_time = nil)
# @return [String]
def create_log(pull_requests, issues, tag_name, tag_time)

github_site = options[:github_site] || 'https://github.com'

# 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:
time_string = tag_time.strftime @options[:format]
Expand Down
9 changes: 8 additions & 1 deletion lib/github_changelog_generator/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def self.parse_options
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
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|
puts "Version: #{GitHubChangelogGenerator::VERSION}"
exit
Expand All @@ -59,8 +65,9 @@ def self.parse_options
parser.parse!

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
match = /(?:.+github\.com\/)?(.+)\/(.+)/.match(ARGV[0])
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])

if match[2].nil?
exit
Expand Down