Merge branch 'release/1.2.3'
This commit is contained in:
commit
fcc1c608a2
|
@ -2,7 +2,7 @@ GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.3.6)
|
addressable (2.3.6)
|
||||||
colorize (0.7.3)
|
colorize (0.7.4)
|
||||||
descendants_tracker (0.0.4)
|
descendants_tracker (0.0.4)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
faraday (0.9.0)
|
faraday (0.9.0)
|
||||||
|
@ -15,13 +15,13 @@ GEM
|
||||||
multi_json (>= 1.7.5, < 2.0)
|
multi_json (>= 1.7.5, < 2.0)
|
||||||
nokogiri (~> 1.6.3)
|
nokogiri (~> 1.6.3)
|
||||||
oauth2
|
oauth2
|
||||||
hashie (3.3.1)
|
hashie (3.3.2)
|
||||||
jwt (1.0.0)
|
jwt (1.2.0)
|
||||||
mini_portile (0.6.1)
|
mini_portile (0.6.1)
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
multi_xml (0.5.5)
|
multi_xml (0.5.5)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
nokogiri (1.6.4)
|
nokogiri (1.6.5)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
oauth2 (1.0.0)
|
oauth2 (1.0.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
faraday (>= 0.8, < 0.10)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
require 'github_api'
|
require 'github_api'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'colorize'
|
require 'colorize'
|
||||||
|
require 'benchmark'
|
||||||
|
|
||||||
require_relative 'github_changelog_generator/parser'
|
require_relative 'github_changelog_generator/parser'
|
||||||
require_relative 'github_changelog_generator/generator'
|
require_relative 'github_changelog_generator/generator'
|
||||||
require_relative 'github_changelog_generator/version'
|
require_relative 'github_changelog_generator/version'
|
||||||
|
@ -12,6 +14,8 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
attr_accessor :options, :all_tags, :github
|
attr_accessor :options, :all_tags, :github
|
||||||
|
|
||||||
|
PER_PAGE_NUMBER = 30
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
|
||||||
@options = Parser.parse_options
|
@options = Parser.parse_options
|
||||||
|
@ -25,9 +29,10 @@ module GitHubChangelogGenerator
|
||||||
github_token
|
github_token
|
||||||
|
|
||||||
if @github_token.nil?
|
if @github_token.nil?
|
||||||
@github = Github.new
|
@github = Github.new per_page: PER_PAGE_NUMBER
|
||||||
else
|
else
|
||||||
@github = Github.new oauth_token: @github_token
|
@github = Github.new oauth_token: @github_token,
|
||||||
|
per_page: PER_PAGE_NUMBER
|
||||||
end
|
end
|
||||||
|
|
||||||
@generator = Generator.new(@options)
|
@generator = Generator.new(@options)
|
||||||
|
@ -56,18 +61,23 @@ module GitHubChangelogGenerator
|
||||||
def get_all_closed_pull_requests
|
def get_all_closed_pull_requests
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Fetching pull requests..'
|
print "Fetching pull requests...\r"
|
||||||
end
|
end
|
||||||
|
|
||||||
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
|
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
|
||||||
|
|
||||||
pull_requests = []
|
pull_requests = []
|
||||||
|
page_i = 0
|
||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
|
page_i += PER_PAGE_NUMBER
|
||||||
|
print "Fetching pull requests... #{page_i}\r"
|
||||||
pull_requests.concat(page)
|
pull_requests.concat(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print "\r"
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Received all closed pull requests: #{pull_requests.count}"
|
puts "Received closed pull requests: #{pull_requests.count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @options[:pull_request_labels].nil?
|
unless @options[:pull_request_labels].nil?
|
||||||
|
@ -148,8 +158,13 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
def generate_log_for_all_tags
|
def generate_log_for_all_tags
|
||||||
log = ''
|
log = ''
|
||||||
@all_tags.each { |tag| self.get_time_of_tag(tag) }
|
|
||||||
|
|
||||||
|
# Async fetching tags:
|
||||||
|
threads = []
|
||||||
|
@all_tags.each { |tag|
|
||||||
|
threads << Thread.new { self.get_time_of_tag(tag) }
|
||||||
|
}
|
||||||
|
threads.each { |thr| thr.join }
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Sorting tags.."
|
puts "Sorting tags.."
|
||||||
|
@ -177,16 +192,19 @@ module GitHubChangelogGenerator
|
||||||
def get_all_tags
|
def get_all_tags
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Fetching all tags..'
|
print "Fetching tags...\r"
|
||||||
end
|
end
|
||||||
|
|
||||||
response = @github.repos.tags @options[:user], @options[:project]
|
response = @github.repos.tags @options[:user], @options[:project]
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
|
page_i = 0
|
||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
|
page_i += PER_PAGE_NUMBER
|
||||||
|
print "Fetching tags... #{page_i}\r"
|
||||||
tags.concat(page)
|
tags.concat(page)
|
||||||
end
|
end
|
||||||
|
print "\r"
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Found #{tags.count} tags"
|
puts "Found #{tags.count} tags"
|
||||||
end
|
end
|
||||||
|
@ -329,10 +347,6 @@ module GitHubChangelogGenerator
|
||||||
return @tag_times_hash[prev_tag['name']]
|
return @tag_times_hash[prev_tag['name']]
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:verbose]
|
|
||||||
puts "Getting time for tag #{prev_tag['name']}"
|
|
||||||
end
|
|
||||||
|
|
||||||
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], prev_tag['commit']['sha']
|
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], prev_tag['commit']['sha']
|
||||||
time_string = github_git_data_commits_get['committer']['date']
|
time_string = github_git_data_commits_get['committer']['date']
|
||||||
Time.parse(time_string)
|
Time.parse(time_string)
|
||||||
|
@ -341,13 +355,22 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
def get_all_issues
|
def get_all_issues
|
||||||
|
|
||||||
|
if @options[:verbose]
|
||||||
|
print "Fetching closed issues...\r"
|
||||||
|
end
|
||||||
|
|
||||||
response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
|
response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
|
||||||
|
|
||||||
issues = []
|
issues = []
|
||||||
|
page_i = 0
|
||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
|
page_i += PER_PAGE_NUMBER
|
||||||
|
print "Fetching closed issues... #{page_i}\r"
|
||||||
issues.concat(page)
|
issues.concat(page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print "\r"
|
||||||
|
|
||||||
# remove pull request from issues:
|
# remove pull request from issues:
|
||||||
issues.select! { |x|
|
issues.select! { |x|
|
||||||
x.pull_request == nil
|
x.pull_request == nil
|
||||||
|
@ -357,6 +380,11 @@ module GitHubChangelogGenerator
|
||||||
puts "Received closed issues: #{issues.count}"
|
puts "Received closed issues: #{issues.count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if @options[:verbose]
|
||||||
|
puts "Filtering issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}"
|
||||||
|
end
|
||||||
|
|
||||||
filtered_issues = issues.select { |issue|
|
filtered_issues = issues.select { |issue|
|
||||||
#compare is there any labels from @options[:labels] array
|
#compare is there any labels from @options[:labels] array
|
||||||
(issue.labels.map { |label| label.name } & @options[:labels]).any?
|
(issue.labels.map { |label| label.name } & @options[:labels]).any?
|
||||||
|
@ -371,7 +399,7 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Filter issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count} issues"
|
puts "Filtered issues: #{filtered_issues.count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
filtered_issues
|
filtered_issues
|
||||||
|
|
|
@ -10,7 +10,11 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
||||||
if @options[:author]
|
if @options[:author]
|
||||||
|
if !pull_request.user.nil?
|
||||||
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
||||||
|
else
|
||||||
|
merge += " ({Null user})\n\n"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
merge += "\n\n"
|
merge += "\n\n"
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,15 +58,21 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
#udefined case with 1 parameter:
|
|
||||||
if ARGV[0] && !ARGV[1]
|
if ARGV[0] && !ARGV[1]
|
||||||
puts parser.banner
|
# 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])
|
||||||
|
|
||||||
|
if match[2].nil?
|
||||||
exit
|
exit
|
||||||
|
else
|
||||||
|
options[:user] = match[1]
|
||||||
|
options[:project]= match[2]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !options[:user] && !options[:project]
|
if !options[:user] && !options[:project]
|
||||||
remote = `git remote -vv`.split("\n")
|
remote = `git remote -vv`.split("\n")
|
||||||
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)\.git.*/.match(remote[0])
|
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git)?.*/.match(remote[0])
|
||||||
|
|
||||||
if match && match[1] && match[2]
|
if match && match[1] && match[2]
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
|
@ -83,7 +89,6 @@ module GitHubChangelogGenerator
|
||||||
if ARGV[1]
|
if ARGV[1]
|
||||||
options[:tag1] = ARGV[0]
|
options[:tag1] = ARGV[0]
|
||||||
options[:tag2] = ARGV[1]
|
options[:tag2] = ARGV[1]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
options
|
options
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
VERSION = '1.2.2'
|
VERSION = '1.2.3'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user