Skip to content

Commit 23a9f7c

Browse files
committed
adds mutlithreaded details
1 parent 7c3dc3d commit 23a9f7c

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

repo_checker.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def fetch_statuses
7474

7575
Dir.chdir repo.path
7676
status = `git fetch; git status`
77-
77+
7878
{
7979
repo: repo,
8080
status: status,

updater.rb

+22-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33

44
require 'pp'
55
require 'yaml'
6-
# require 'open3'
6+
require 'open3'
77

88
# Add new books to this array, as necessary
99
@books = ['docs-book-cloudfoundry', 'docs-book-pcfservices', 'docs-book-pivotalcf', 'docs-book-runpivotal']
1010
@modified_repos = []
1111
@repo_list = ["docs-layout-repo", "docs-utility-scripts"]
12+
@output = {}
1213

1314
# Create a list of the book repositories to be cloned_or_updated, send them to cloner/updater, and display the ignored modified repos.
1415
def gather_repos(books)
@@ -21,6 +22,7 @@ def gather_repos(books)
2122
multithread_pipe reduced_list.uniq
2223
# clone_or_update reduced_list.uniq
2324
display_modified_repos @modified_repos
25+
pp @output
2426
end
2527

2628
# Removes repos with changes from @repo_list
@@ -33,12 +35,28 @@ def reduce_list_for_current_work(working_repos_array)
3335

3436
def multithread_pipe(list_of_repos)
3537
threads = []
36-
list_of_repos.each do |repo|
37-
threads << Thread.new { clone_or_update repo}
38-
end
38+
list_of_repos.each{|repo| threads << Thread.new { clone_or_update repo}}
3939
threads.each{|t|t.join}
40+
puts "========\nYour working repos have been updated \n"
4041
end
4142

43+
# def multithread_pipe(list_of_repos)
44+
# threads = []
45+
# list_of_repos.each do |repo|
46+
# threads << Thread.new do
47+
# Open3.popen3(clone_or_update repo) do |stdin, stdout, stderr|
48+
# @output[repo] = "STDOUT: #{stdout.read}"
49+
# @output[repo] = stdin.read
50+
# @output[repo] = "STDERR: #{stderr.read}"
51+
# clone_or_update repo
52+
# end
53+
54+
# end
55+
# end
56+
# pp @output
57+
# threads.each{|t|t.join}
58+
# end
59+
4260
# Ternary operation that checks for directory existence, if none, clones; otherwise updates repo
4361
def clone_or_update(repo)
4462
File.directory?(Dir.home + '/workspace/' + repo.gsub(/\w*-?\w*\//,'')) ? update_repo(repo) : clone_repo(repo)

0 commit comments

Comments
 (0)