implement async fetching tags

This commit is contained in:
Petr Korolev 2014-12-15 14:15:39 +02:00
parent 4ea1058cd5
commit 69dd5eadc2
2 changed files with 12 additions and 9 deletions

View File

@ -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)

View File

@ -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'
@ -148,8 +150,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.."
@ -329,10 +336,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)