git_mass_do 0.0.2 → 0.0.3
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/git_mass_do.gemspec +1 -1
- data/lib/git_mass_do/cli.rb +2 -2
- data/lib/git_mass_do/cloner.rb +17 -15
- data/spec/git_mass_do/cloner_spec.rb +24 -20
- data/spec/git_mass_do/puller_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c60b97924103804b41ef9e06ed00d167c5361ed
|
4
|
+
data.tar.gz: d59cfa7e420513c40a64682229f4668e0df6d000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bea3a14f9e2eb2683aa571e588a6955660b996374144dbbe5adde2bcfd3dab773a1eae14e9bd9578e90bb13d446d8b515ded4365468773c3d0eb9c4932901fd
|
7
|
+
data.tar.gz: a5b5defed62c87fc3469f6873b6d1c46ca7eec4a0395c2f7607ac4915ed6d590b8861b70548ab44bba14db41a6f4261847682e5e27a600e9f31112fbf156f67c
|
data/Gemfile.lock
CHANGED
data/git_mass_do.gemspec
CHANGED
data/lib/git_mass_do/cli.rb
CHANGED
@@ -10,8 +10,8 @@ module GitMassDo
|
|
10
10
|
end
|
11
11
|
|
12
12
|
desc 'git_mass_do clone :username', 'Git pulls all repositories contained in current directory.'
|
13
|
-
def clone(username)
|
14
|
-
Cloner.new(username).
|
13
|
+
def clone(username, dir = Dir.pwd)
|
14
|
+
Cloner.new(username, dir).clone!
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/git_mass_do/cloner.rb
CHANGED
@@ -5,21 +5,11 @@ module GitMassDo
|
|
5
5
|
class Cloner
|
6
6
|
include Process
|
7
7
|
|
8
|
-
def initialize(username)
|
8
|
+
def initialize(username, dir = Dir.pwd)
|
9
9
|
@username = username
|
10
|
+
@dir = dir
|
10
11
|
end
|
11
12
|
|
12
|
-
def clone_em_all!(repos)
|
13
|
-
repos.map do |repo|
|
14
|
-
spawn(make_command(repo))
|
15
|
-
end
|
16
|
-
waitall.map { |_, status| status }
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :username
|
22
|
-
|
23
13
|
def clone!
|
24
14
|
start_time = Time.now
|
25
15
|
repos = RepositoryFetcher.get_all_repos_from_user(username)
|
@@ -28,13 +18,25 @@ module GitMassDo
|
|
28
18
|
OutputFormatter.format(repos, statuses, start_time)
|
29
19
|
end
|
30
20
|
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :username, :dir
|
24
|
+
|
25
|
+
def clone_em_all!(repos)
|
26
|
+
repos.map do |repo|
|
27
|
+
spawn(make_command(repo))
|
28
|
+
end
|
29
|
+
waitall.map { |_, status| status }
|
30
|
+
end
|
31
|
+
|
31
32
|
def make_command(repo)
|
32
33
|
if repo.fork
|
33
34
|
parent_repo = RepositoryFetcher.get_repo(repo.url).parent
|
34
|
-
"git clone #{repo.ssh_url} && \
|
35
|
-
git -C #{repo.name} remote add upstream
|
35
|
+
"git clone #{repo.ssh_url} #{ File.join(dir, repo.name) } && \
|
36
|
+
git -C \"#{ File.join(dir, repo.name) }\" remote add upstream \
|
37
|
+
#{parent_repo.ssh_url} --fetch"
|
36
38
|
else
|
37
|
-
"git clone #{repo.ssh_url}"
|
39
|
+
"git clone #{repo.ssh_url} #{ File.join(dir, repo.name) }"
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -1,38 +1,40 @@
|
|
1
1
|
module GitMassDo
|
2
2
|
describe Cloner do
|
3
|
-
subject(:cloner) { described_class.new(username) }
|
3
|
+
subject(:cloner) { described_class.new(username, dir) }
|
4
4
|
|
5
5
|
let(:username) { 'ironman' }
|
6
|
+
let(:dir) { '/kifita/' }
|
6
7
|
|
7
|
-
let(:repo)
|
8
|
+
let(:repo) do
|
9
|
+
double(
|
10
|
+
:repo,
|
11
|
+
ssh_url: 'git@hubgit.com:bar/foo',
|
12
|
+
url: 'http://hubgit.com/bar/foo',
|
13
|
+
fork: false,
|
14
|
+
name: 'foo')
|
15
|
+
end
|
8
16
|
let(:repos) { [repo] * 3 }
|
9
17
|
|
10
18
|
before do
|
11
19
|
allow(cloner).to receive(:spawn).and_return(nil)
|
12
20
|
allow(cloner).to receive(:waitall).and_return([])
|
21
|
+
|
22
|
+
allow(RepositoryFetcher).to receive(:get_all_repos_from_user)
|
23
|
+
.and_return(repos)
|
24
|
+
allow(OutputFormatter).to receive(:format)
|
13
25
|
end
|
14
26
|
|
15
|
-
describe '#
|
16
|
-
subject(:
|
27
|
+
describe '#clone!' do
|
28
|
+
subject(:clone!) { cloner.clone! }
|
17
29
|
|
18
30
|
it 'spawns a clone job for each repo' do
|
19
31
|
expect(cloner).to receive(:spawn)
|
20
|
-
.with("git clone #{repo.ssh_url}").exactly(3).times
|
32
|
+
.with("git clone #{repo.ssh_url} /kifita/foo").exactly(3).times
|
21
33
|
|
22
|
-
|
34
|
+
clone!
|
23
35
|
end
|
24
36
|
|
25
37
|
context 'when repo is a fork'do
|
26
|
-
let(:repo) do
|
27
|
-
double(
|
28
|
-
:repo,
|
29
|
-
ssh_url: 'git@hubgit.com:bar/foo',
|
30
|
-
url: 'http://hubgit.com/bar/foo',
|
31
|
-
fork: true,
|
32
|
-
name: 'bar'
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
38
|
let(:parent_repo) do
|
37
39
|
double(:parent, ssh_url: 'git@hubgit.com:parent/repo')
|
38
40
|
end
|
@@ -41,24 +43,26 @@ module GitMassDo
|
|
41
43
|
allow(RepositoryFetcher).to receive_message_chain(
|
42
44
|
:get_repo, :parent
|
43
45
|
).and_return(parent_repo)
|
46
|
+
|
47
|
+
allow(repo).to receive(:fork).and_return(true)
|
44
48
|
end
|
45
49
|
|
46
50
|
it 'gets parent repository by url' do
|
47
51
|
expect(RepositoryFetcher).to receive(:get_repo)
|
48
52
|
.with(repo.url)
|
49
53
|
|
50
|
-
|
54
|
+
clone!
|
51
55
|
end
|
52
56
|
|
53
57
|
it 'adds upstream remote' do
|
54
58
|
expect(cloner).to receive(:spawn)
|
55
59
|
.with(
|
56
|
-
"git clone #{repo.ssh_url} && \
|
57
|
-
git -C
|
60
|
+
"git clone #{repo.ssh_url} /kifita/foo && \
|
61
|
+
git -C \"/kifita/foo\" remote add upstream #{parent_repo.ssh_url} \
|
58
62
|
--fetch"
|
59
63
|
)
|
60
64
|
|
61
|
-
|
65
|
+
clone!
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -21,7 +21,7 @@ describe GitMassDo::Puller do
|
|
21
21
|
|
22
22
|
it 'issues a git pull command for each entry in dir' do
|
23
23
|
entries.each do |entry|
|
24
|
-
expect(puller).to receive(:spawn).with("git -C #{entry} pull origin")
|
24
|
+
expect(puller).to receive(:spawn).with("git -C #{entry} pull -r origin")
|
25
25
|
end
|
26
26
|
|
27
27
|
pull
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_mass_do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: recursive-open-struct
|