git_multicast 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/git_multicast/adapters.rb +3 -1
- data/lib/git_multicast/cloner.rb +22 -4
- data/lib/git_multicast/output_formatter.rb +11 -8
- data/lib/git_multicast/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/clone_repos.yml +1694 -0
- data/spec/fixtures/vcr_cassettes/github_repo_parent.yml +1 -1
- data/spec/git_multicast/cloner_spec.rb +34 -39
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2d0bdfccafad675de94f29e53e2b85e9cad62b1
|
4
|
+
data.tar.gz: fc56b9016cf59f35856aed2c677cd6819af66a14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c28ef49cf18cd09198685d1305b7d21efbc1867b0bf533ae1d1567543ecb90242e748d3ed9977e71983d1f08e1047491caab3e5463316e09a8bc86fba4959a63
|
7
|
+
data.tar.gz: 436daa09aaffc718d6f7e6a59840ca658c2f675a7c1c96b237032b425fcd5e041b4b3c2a76574fb11c56efe4f72aa430b7547aa62ff5b3a4de8dd3cd5068adf5
|
data/Gemfile.lock
CHANGED
data/lib/git_multicast/cloner.rb
CHANGED
@@ -13,9 +13,9 @@ module GitMulticast
|
|
13
13
|
def clone!
|
14
14
|
start_time = Time.now
|
15
15
|
repos = RepositoryFetcher.get_all_repos_from_user(username)
|
16
|
-
|
16
|
+
output_status_zip = clone_em_all!(repos)
|
17
17
|
|
18
|
-
OutputFormatter.format(
|
18
|
+
OutputFormatter.format(output_status_zip, start_time)
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
@@ -23,10 +23,28 @@ module GitMulticast
|
|
23
23
|
attr_reader :username, :dir
|
24
24
|
|
25
25
|
def clone_em_all!(repos)
|
26
|
+
streams = spawn_processes(repos)
|
27
|
+
|
28
|
+
_, statuses = waitall.transpose
|
29
|
+
|
30
|
+
output = read_output(streams)
|
31
|
+
output.zip(statuses)
|
32
|
+
end
|
33
|
+
|
34
|
+
def spawn_processes(repos)
|
26
35
|
repos.map do |repo|
|
27
|
-
|
36
|
+
r, w = IO.pipe
|
37
|
+
w.write("Clonning: #{repo.name}\n")
|
38
|
+
spawn(make_command(repo), out: w, err: w)
|
39
|
+
[r, w]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def read_output(streams)
|
44
|
+
streams.map do |r, w|
|
45
|
+
w.close unless w.closed?
|
46
|
+
r.read
|
28
47
|
end
|
29
|
-
waitall.map { |_, status| status }
|
30
48
|
end
|
31
49
|
|
32
50
|
def make_command(repo)
|
@@ -1,16 +1,19 @@
|
|
1
1
|
module GitMulticast
|
2
2
|
class OutputFormatter
|
3
|
-
def self.format(
|
4
|
-
repo_status_pairs = repos.zip(statuses)
|
5
|
-
|
3
|
+
def self.format(output_status_zip, start_time = nil)
|
6
4
|
# get successes and failures
|
7
|
-
success_pairs =
|
8
|
-
failure_pairs =
|
5
|
+
success_pairs = output_status_zip.select { |_, status| status.success? }
|
6
|
+
failure_pairs = output_status_zip.reject { |_, status| status.success? }
|
9
7
|
|
10
|
-
success_pairs.each
|
11
|
-
|
8
|
+
success_pairs.each do |output, _|
|
9
|
+
puts(
|
10
|
+
"#{output} \nsuccess.\n" \
|
11
|
+
'=============================================='
|
12
|
+
)
|
13
|
+
end
|
14
|
+
failure_pairs.each { |output, _| puts "#{output}\nFAILURE!!" }
|
12
15
|
|
13
|
-
puts '
|
16
|
+
puts '#############################################'
|
14
17
|
puts "Finished in #{Time.now - start_time} seconds." if start_time
|
15
18
|
end
|
16
19
|
end
|