git_multicast 0.2.0 → 0.3.0
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/cli.rb +14 -2
- data/lib/git_multicast/multicaster.rb +1 -0
- data/lib/git_multicast/multicaster/generic.rb +31 -0
- data/lib/git_multicast/multicaster/pull.rb +2 -23
- data/lib/git_multicast/version.rb +1 -1
- data/spec/git_multicast/cli_spec.rb +10 -0
- data/spec/git_multicast/multicaster/generic_spec.rb +43 -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: fcd2ce8c7a7c7b5c661a85f2cc4f6eb9d4160cd0
|
4
|
+
data.tar.gz: 2078820519daa9dbad320b526a841d51d576016a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3122aad848355fb6ea23aaaa6f5108cb090b5b9a7fc6dd22b6742a8b5759f7c786a4938dffd1bd38dd5e82834ae532f9100b106860809dfc56b5a34f1dbdd284
|
7
|
+
data.tar.gz: 3886bb80fce62fbd54790536cf2d04cde3dc2b45905058686162627335744cb1c21a81948f18ef8c8c90d6599eec25c3bc145eec14a7ca70bfbde333cb3e0a39
|
data/Gemfile.lock
CHANGED
data/lib/git_multicast/cli.rb
CHANGED
@@ -4,7 +4,7 @@ require 'git_multicast'
|
|
4
4
|
|
5
5
|
module GitMulticast
|
6
6
|
class Cli < Thor
|
7
|
-
class_option :version, :
|
7
|
+
class_option :version, type: :boolean
|
8
8
|
|
9
9
|
desc 'git_multicast pull', 'Git pulls all repositories contained in\
|
10
10
|
current directory.'
|
@@ -18,6 +18,18 @@ module GitMulticast
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
desc 'git_multicast cast :command', 'Casts custom command to all git\
|
22
|
+
repositories in current directory.'
|
23
|
+
option :quiet, type: :boolean
|
24
|
+
option :verbose, type: :boolean
|
25
|
+
def cast(command)
|
26
|
+
if formatter
|
27
|
+
puts multicaster(:generic).new(Dir.pwd, command, formatter).execute!
|
28
|
+
else
|
29
|
+
puts multicaster(:generic).new(Dir.pwd, command).execute!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
21
33
|
desc 'git_multicast clone :username', 'Git clone all repositories\
|
22
34
|
for given username.'
|
23
35
|
option :quiet, type: :boolean
|
@@ -35,7 +47,7 @@ module GitMulticast
|
|
35
47
|
puts multicaster(:status).new(Dir.pwd).execute!
|
36
48
|
end
|
37
49
|
|
38
|
-
desc
|
50
|
+
desc 'version', 'Show thor_app version'
|
39
51
|
def version
|
40
52
|
puts GitMulticast::VERSION
|
41
53
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GitMulticast
|
2
|
+
class Multicaster
|
3
|
+
class Generic < Multicaster
|
4
|
+
def initialize(dir, command, formatter = Formatter::Standard.new(Time.now))
|
5
|
+
@dir = dir
|
6
|
+
@command = command
|
7
|
+
|
8
|
+
super(formatter)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
attr_reader :dir
|
14
|
+
|
15
|
+
def tasks
|
16
|
+
Dir.entries(dir)
|
17
|
+
.select { |f| File.directory? f }
|
18
|
+
.reject { |f| f =~ /^\./ } # ., .. and .git and the like
|
19
|
+
.map { |dir| Task.new(description(dir), command(dir)) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def command(dir)
|
23
|
+
"git -C #{dir} #{@command}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def description(dir)
|
27
|
+
File.basename(dir)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,29 +1,8 @@
|
|
1
1
|
module GitMulticast
|
2
2
|
class Multicaster
|
3
|
-
class Pull <
|
3
|
+
class Pull < Generic
|
4
4
|
def initialize(dir, formatter = Formatter::Standard.new(Time.now))
|
5
|
-
|
6
|
-
|
7
|
-
super(formatter)
|
8
|
-
end
|
9
|
-
|
10
|
-
protected
|
11
|
-
|
12
|
-
attr_reader :dir
|
13
|
-
|
14
|
-
def tasks
|
15
|
-
Dir.entries(dir)
|
16
|
-
.select { |f| File.directory? f }
|
17
|
-
.reject { |f| f =~ /^\./ } # ., .. and .git and the like
|
18
|
-
.map { |dir| Task.new(description(dir), command(dir)) }
|
19
|
-
end
|
20
|
-
|
21
|
-
def command(dir)
|
22
|
-
"git -C #{dir} pull -r origin"
|
23
|
-
end
|
24
|
-
|
25
|
-
def description(dir)
|
26
|
-
File.basename(dir)
|
5
|
+
super(dir, 'pull -r origin', formatter)
|
27
6
|
end
|
28
7
|
end
|
29
8
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GitMulticast
|
2
|
+
class Multicaster
|
3
|
+
describe Generic do
|
4
|
+
subject(:generic) { described_class.new(dir, command) }
|
5
|
+
|
6
|
+
let(:dir) { '/home/' }
|
7
|
+
let(:entries) { %w(one two) }
|
8
|
+
|
9
|
+
let(:task) { instance_double(Task, call: result) }
|
10
|
+
let(:result) { Task::Result.new('fitas', 'success', 0) }
|
11
|
+
|
12
|
+
let(:command) { 'pull -r origin' }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(File).to receive(:directory?).and_return(true)
|
16
|
+
allow(Dir).to receive(:entries).and_return(entries)
|
17
|
+
|
18
|
+
allow(Task).to receive(:new)
|
19
|
+
.and_return(task)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#execute!' do
|
23
|
+
subject(:execute!) { generic.execute! }
|
24
|
+
|
25
|
+
it 'creates a task for each repository' do
|
26
|
+
entries.each do |entry|
|
27
|
+
expect(Task).to receive(:new)
|
28
|
+
.with(entry, "git -C #{entry} pull -r origin")
|
29
|
+
end
|
30
|
+
|
31
|
+
execute!
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'runs tasks using a runner' do
|
35
|
+
expect(Task::Runner).to receive(:new)
|
36
|
+
.with([task, task]).and_call_original
|
37
|
+
|
38
|
+
execute!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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.
|
4
|
+
version: 0.3.0
|
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-12-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: recursive-open-struct
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/git_multicast/formatter/status.rb
|
211
211
|
- lib/git_multicast/multicaster.rb
|
212
212
|
- lib/git_multicast/multicaster/clone.rb
|
213
|
+
- lib/git_multicast/multicaster/generic.rb
|
213
214
|
- lib/git_multicast/multicaster/pull.rb
|
214
215
|
- lib/git_multicast/multicaster/status.rb
|
215
216
|
- lib/git_multicast/repository_fetcher.rb
|
@@ -233,6 +234,7 @@ files:
|
|
233
234
|
- spec/git_multicast/formatter/standard_spec.rb
|
234
235
|
- spec/git_multicast/formatter/status_spec.rb
|
235
236
|
- spec/git_multicast/multicaster/clone_spec.rb
|
237
|
+
- spec/git_multicast/multicaster/generic_spec.rb
|
236
238
|
- spec/git_multicast/multicaster/pull_spec.rb
|
237
239
|
- spec/git_multicast/multicaster/status_spec.rb
|
238
240
|
- spec/git_multicast/repository_fetcher/bitbucket_spec.rb
|