git_multicast 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/git_multicast/cli.rb +5 -0
- data/lib/git_multicast/statuser.rb +42 -0
- data/lib/git_multicast/version.rb +1 -1
- data/lib/git_multicast.rb +1 -0
- data/spec/git_multicast/statuser_spec.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88114b607c36efdb71e8a3ab4434a9be536a64d
|
4
|
+
data.tar.gz: 66adbc427e63be01db1dc6acdba5691131ad66dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aca164e70a06e11308990ccf341358370ae9a89eefa3e7f4e679c2fb307c2152d18df904ca8c463268edcced7827eb5b16c1d89ab6da8264bd1e286952091853
|
7
|
+
data.tar.gz: 4e9e56f128245aa1ce104f5ac2686ed2f9343d44f7579bc25b4f4452c845af50846c3d815ad6a4d476f474c1aee226e04130fbbc9ac71d1f3f3c20365a09febc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![git_multicast API Documentation](https://www.omniref.com/ruby/gems/git_multicast.png)](https://www.omniref.com/ruby/gems/git_multicast)
|
2
|
+
|
1
3
|
# Multicast your git actions.
|
2
4
|
|
3
5
|
Have you ever need to clone a whole bunch of repositories? Have you forgot to pull remote changes?
|
data/lib/git_multicast/cli.rb
CHANGED
@@ -16,6 +16,11 @@ module GitMulticast
|
|
16
16
|
Cloner.new(username, Dir.pwd).clone!
|
17
17
|
end
|
18
18
|
|
19
|
+
desc 'git_multicast status', 'Shows status for each repository'
|
20
|
+
def status
|
21
|
+
Statuser.new(Dir.pwd).get_statuses
|
22
|
+
end
|
23
|
+
|
19
24
|
desc 'git_multicast version', 'Shows currently installed version'
|
20
25
|
def version
|
21
26
|
puts GitMulticast::VERSION
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module GitMulticast
|
2
|
+
class Statuser
|
3
|
+
include Process
|
4
|
+
|
5
|
+
attr_reader :dir
|
6
|
+
|
7
|
+
def initialize(dir)
|
8
|
+
@dir = dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_statuses
|
12
|
+
start_time = Time.now
|
13
|
+
output_status_zip = statuses
|
14
|
+
|
15
|
+
OutputFormatter.format(output_status_zip, start_time)
|
16
|
+
end
|
17
|
+
|
18
|
+
def statuses
|
19
|
+
dirs = Dir.entries(dir)
|
20
|
+
.select { |f| File.directory? f }
|
21
|
+
.reject { |f| f =~ /^\./ } # ., .. and .git and the like
|
22
|
+
|
23
|
+
streams = dirs.map do |dir|
|
24
|
+
r, w = IO.pipe
|
25
|
+
w.write("Repo: #{dir}\n")
|
26
|
+
spawn("cd #{dir} && git status", out: w, err: w)
|
27
|
+
[r, w]
|
28
|
+
end
|
29
|
+
_, statuses = waitall.transpose
|
30
|
+
|
31
|
+
output = read_output(streams)
|
32
|
+
output.zip(statuses)
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_output(streams)
|
36
|
+
streams.map do |r, w|
|
37
|
+
w.close unless w.closed?
|
38
|
+
r.read
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/git_multicast.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'git_multicast/version'
|
|
2
2
|
require_relative 'git_multicast/cloner'
|
3
3
|
require_relative 'git_multicast/puller'
|
4
4
|
require_relative 'git_multicast/output_formatter'
|
5
|
+
require_relative 'git_multicast/statuser'
|
5
6
|
|
6
7
|
require_relative 'git_multicast/adapters'
|
7
8
|
require_relative 'git_multicast/repository_fetcher'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module GitMulticast
|
2
|
+
describe Statuser do
|
3
|
+
subject(:statuser) { described_class.new(dir) }
|
4
|
+
|
5
|
+
let(:dir) { '/ki/fita/' }
|
6
|
+
let(:entries) { ['fita1', 'fita2'] }
|
7
|
+
|
8
|
+
let(:pipe) { IO.pipe }
|
9
|
+
let(:r) { pipe.first }
|
10
|
+
let(:w) { pipe[1] }
|
11
|
+
|
12
|
+
before do
|
13
|
+
$stdout = StringIO.new
|
14
|
+
|
15
|
+
allow(statuser).to receive(:spawn).and_return(nil)
|
16
|
+
allow(statuser).to receive(:waitall).and_return(
|
17
|
+
[[nil, double(:success, success?: true)]] * 32
|
18
|
+
)
|
19
|
+
|
20
|
+
allow(IO).to receive(:pipe).and_return([r, w])
|
21
|
+
allow(File).to receive(:directory?).and_return(true)
|
22
|
+
allow(Dir).to receive(:entries).and_return(entries)
|
23
|
+
|
24
|
+
allow(OutputFormatter).to receive(:format)
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
$stdout = STDOUT
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#get_statuses' do
|
32
|
+
subject(:get_statuses) { statuser.get_statuses }
|
33
|
+
|
34
|
+
it 'spawns a clone job for each repo' do
|
35
|
+
entries.each do |entry|
|
36
|
+
expect(statuser).to receive(:spawn)
|
37
|
+
.with("cd #{entry} && git status", out: w, err: w)
|
38
|
+
end
|
39
|
+
|
40
|
+
get_statuses
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_multicast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renan Ranelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: recursive-open-struct
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/git_multicast/repository_fetcher.rb
|
181
181
|
- lib/git_multicast/repository_fetcher/bitbucket.rb
|
182
182
|
- lib/git_multicast/repository_fetcher/github.rb
|
183
|
+
- lib/git_multicast/statuser.rb
|
183
184
|
- lib/git_multicast/version.rb
|
184
185
|
- spec/fixtures/vcr_cassettes/bitbucket_all_user_repos.yml
|
185
186
|
- spec/fixtures/vcr_cassettes/bitbucket_repo.yml
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- spec/git_multicast/repository_fetcher/bitbucket_spec.rb
|
195
196
|
- spec/git_multicast/repository_fetcher/github_spec.rb
|
196
197
|
- spec/git_multicast/repository_fetcher_spec.rb
|
198
|
+
- spec/git_multicast/statuser_spec.rb
|
197
199
|
- spec/spec_helper.rb
|
198
200
|
homepage: http://github.com/rranelli/git_multicast
|
199
201
|
licenses:
|