33
44require 'pp'
55require '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.
1415def 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
2426end
2527
2628# Removes repos with changes from @repo_list
@@ -33,12 +35,28 @@ def reduce_list_for_current_work(working_repos_array)
3335
3436def 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 "========\n Your working repos have been updated \n "
4041end
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
4361def clone_or_update ( repo )
4462 File . directory? ( Dir . home + '/workspace/' + repo . gsub ( /\w *-?\w *\/ / , '' ) ) ? update_repo ( repo ) : clone_repo ( repo )
0 commit comments