3
3
4
4
require 'pp'
5
5
require 'yaml'
6
- # require 'open3'
6
+ require 'open3'
7
7
8
8
# Add new books to this array, as necessary
9
9
@books = [ 'docs-book-cloudfoundry' , 'docs-book-pcfservices' , 'docs-book-pivotalcf' , 'docs-book-runpivotal' ]
10
10
@modified_repos = [ ]
11
11
@repo_list = [ "docs-layout-repo" , "docs-utility-scripts" ]
12
+ @output = { }
12
13
13
14
# Create a list of the book repositories to be cloned_or_updated, send them to cloner/updater, and display the ignored modified repos.
14
15
def gather_repos ( books )
@@ -21,6 +22,7 @@ def gather_repos(books)
21
22
multithread_pipe reduced_list . uniq
22
23
# clone_or_update reduced_list.uniq
23
24
display_modified_repos @modified_repos
25
+ pp @output
24
26
end
25
27
26
28
# Removes repos with changes from @repo_list
@@ -33,12 +35,28 @@ def reduce_list_for_current_work(working_repos_array)
33
35
34
36
def multithread_pipe ( list_of_repos )
35
37
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 } }
39
39
threads . each { |t |t . join }
40
+ puts "========\n Your working repos have been updated \n "
40
41
end
41
42
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
+
42
60
# Ternary operation that checks for directory existence, if none, clones; otherwise updates repo
43
61
def clone_or_update ( repo )
44
62
File . directory? ( Dir . home + '/workspace/' + repo . gsub ( /\w *-?\w *\/ / , '' ) ) ? update_repo ( repo ) : clone_repo ( repo )
0 commit comments