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