git_multicast 0.0.5 → 0.0.6
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/.rubocop.yml +11 -0
- data/Gemfile.lock +17 -1
- data/README.md +3 -3
- data/git_multicast.gemspec +29 -18
- data/lib/git_multicast/.rubocop.yml +11 -0
- data/lib/git_multicast/adapters/bitbucket.rb +35 -0
- data/lib/git_multicast/adapters/github.rb +17 -0
- data/lib/git_multicast/adapters.rb +5 -0
- data/lib/git_multicast/cli.rb +9 -2
- data/lib/git_multicast/cloner.rb +3 -3
- data/lib/git_multicast/output_formatter.rb +12 -10
- data/lib/git_multicast/repository_fetcher/bitbucket.rb +34 -0
- data/lib/git_multicast/repository_fetcher/github.rb +25 -0
- data/lib/git_multicast/repository_fetcher.rb +33 -14
- data/lib/git_multicast/version.rb +1 -1
- data/lib/git_multicast.rb +1 -3
- data/spec/fixtures/vcr_cassettes/bitbucket_all_user_repos.yml +170 -0
- data/spec/fixtures/vcr_cassettes/bitbucket_repo.yml +79 -0
- data/spec/fixtures/vcr_cassettes/github_all_user_repos.yml +107 -0
- data/spec/fixtures/vcr_cassettes/github_repo.yml +77 -0
- data/spec/fixtures/vcr_cassettes/github_repo_parent.yml +79 -0
- data/spec/fixtures/vcr_cassettes/repos_from_all_services.yml +274 -0
- data/spec/git_multicast/adapters/bitbucket_spec.rb +25 -0
- data/spec/git_multicast/puller_spec.rb +4 -0
- data/spec/git_multicast/repository_fetcher/bitbucket_spec.rb +80 -0
- data/spec/git_multicast/repository_fetcher/github_spec.rb +81 -0
- data/spec/git_multicast/repository_fetcher_spec.rb +101 -18
- data/spec/spec_helper.rb +5 -3
- metadata +76 -9
- data/lib/git_multicast/bitbucket_adapter.rb +0 -33
- data/lib/git_multicast/bitbucket_fetcher.rb +0 -36
- data/lib/git_multicast/github_fetcher.rb +0 -31
- data/spec/git_multicast/bitbucket_adapter_spec.rb +0 -25
- data/spec/git_multicast/bitbucket_fetcher_spec.rb +0 -97
- data/spec/git_multicast/github_fetcher_spec.rb +0 -74
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module GitMulticast
|
|
2
|
+
describe Adapters::Bitbucket do
|
|
3
|
+
subject(:adapter) { described_class.new(repo) }
|
|
4
|
+
|
|
5
|
+
describe '#adapt' do
|
|
6
|
+
subject(:adapt) { adapter.adapt }
|
|
7
|
+
|
|
8
|
+
let(:url) do
|
|
9
|
+
'https://bitbucket.org/api/2.0/repositories/rranelli/cronofaker'
|
|
10
|
+
end
|
|
11
|
+
let(:repo) { RepositoryFetcher::Bitbucket.get_repo(url) }
|
|
12
|
+
|
|
13
|
+
# I know this is ugly, but well...
|
|
14
|
+
it do
|
|
15
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
16
|
+
expect(adapt.url).to eq('https://bitbucket.org/api/2.0/repositories/rranelli/cronofaker')
|
|
17
|
+
expect(adapt.ssh_url).to eq('ssh://git@bitbucket.org/rranelli/cronofaker.git')
|
|
18
|
+
expect(adapt.name).to eq('CronoFaker')
|
|
19
|
+
expect(adapt.fork).to be_falsy
|
|
20
|
+
expect(adapt.parent).to be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module GitMulticast
|
|
2
|
+
describe RepositoryFetcher::Bitbucket do
|
|
3
|
+
subject(:fetcher) { described_class }
|
|
4
|
+
|
|
5
|
+
describe '.get_repo' do
|
|
6
|
+
subject(:get_repo) { fetcher.get_repo(url) }
|
|
7
|
+
|
|
8
|
+
let(:url) do
|
|
9
|
+
'https://bitbucket.org/api/2.0/repositories/rranelli/cronofaker'
|
|
10
|
+
end
|
|
11
|
+
let(:json) do
|
|
12
|
+
{ 'links' => { 'clone' => 'I be a body' } }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
allow(JSON).to receive(:parse).and_return(json)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'calls http get' do
|
|
20
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
21
|
+
expect(Net::HTTP).to receive(:get_response)
|
|
22
|
+
.with(URI(url)).and_call_original
|
|
23
|
+
|
|
24
|
+
get_repo
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'parses the resulting json' do
|
|
29
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
30
|
+
expect(JSON).to receive(:parse)
|
|
31
|
+
|
|
32
|
+
get_repo
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'makes a struct with the result body' do
|
|
37
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
38
|
+
expect(RecursiveOpenStruct).to receive(:new)
|
|
39
|
+
.with(json, recurse_over_arrays: true)
|
|
40
|
+
|
|
41
|
+
get_repo
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '.get_all_repos_from_user' do
|
|
47
|
+
subject(:get_all_repos_from_user) do
|
|
48
|
+
fetcher.get_all_repos_from_user(user)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
let(:user) { 'rranelli' }
|
|
52
|
+
let(:url) { URI('https://bitbucket.org/api/2.0/repositories/rranelli') }
|
|
53
|
+
|
|
54
|
+
it 'calls http get' do
|
|
55
|
+
VCR.use_cassette('bitbucket_all_user_repos') do
|
|
56
|
+
expect(Net::HTTP).to receive(:get_response)
|
|
57
|
+
.with(url).and_call_original
|
|
58
|
+
|
|
59
|
+
get_all_repos_from_user
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'parses the resulting json' do
|
|
64
|
+
VCR.use_cassette('bitbucket_all_user_repos') do
|
|
65
|
+
expect(JSON).to receive(:parse).and_call_original
|
|
66
|
+
|
|
67
|
+
get_all_repos_from_user
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'builds each repository as a RecursiveOpenStruct' do
|
|
72
|
+
VCR.use_cassette('bitbucket_all_user_repos') do
|
|
73
|
+
expect(RecursiveOpenStruct).to receive(:new).exactly(3).times
|
|
74
|
+
|
|
75
|
+
get_all_repos_from_user
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module GitMulticast
|
|
2
|
+
describe RepositoryFetcher::Github do
|
|
3
|
+
subject(:fetcher) { described_class }
|
|
4
|
+
|
|
5
|
+
let(:uri) { URI(url) }
|
|
6
|
+
|
|
7
|
+
describe '.get_repo' do
|
|
8
|
+
subject(:get_repo) { fetcher.get_repo(url) }
|
|
9
|
+
|
|
10
|
+
let(:url) { 'https://api.github.com/repos/rranelli/git_multicast' }
|
|
11
|
+
let(:json) do
|
|
12
|
+
{ 'value' => 'I be a body' }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
allow(JSON).to receive(:parse).and_return(json)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'calls http get' do
|
|
20
|
+
VCR.use_cassette('github_repo') do
|
|
21
|
+
expect(Net::HTTP).to receive(:get_response)
|
|
22
|
+
.with(uri).and_call_original
|
|
23
|
+
|
|
24
|
+
get_repo
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'parses the resulting json' do
|
|
29
|
+
VCR.use_cassette('github_repo') do
|
|
30
|
+
expect(JSON).to receive(:parse)
|
|
31
|
+
|
|
32
|
+
get_repo
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'Makes a struct with the result body' do
|
|
37
|
+
VCR.use_cassette('github_repo') do
|
|
38
|
+
expect(RecursiveOpenStruct).to receive(:new).with(
|
|
39
|
+
json, recurse_over_arrays: true
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
get_repo
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '.get_all_repos_from_user' do
|
|
48
|
+
subject(:get_all_repos_from_user) do
|
|
49
|
+
fetcher.get_all_repos_from_user(user)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
let(:user) { 'rranelli' }
|
|
53
|
+
let(:url) { 'https://api.github.com/users/rranelli/repos' }
|
|
54
|
+
|
|
55
|
+
it 'calls http get' do
|
|
56
|
+
VCR.use_cassette('github_all_user_repos') do
|
|
57
|
+
expect(Net::HTTP).to receive(:get_response)
|
|
58
|
+
.with(uri).and_call_original
|
|
59
|
+
|
|
60
|
+
get_all_repos_from_user
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'parses the resulting json' do
|
|
65
|
+
VCR.use_cassette('github_all_user_repos') do
|
|
66
|
+
expect(JSON).to receive(:parse).and_call_original
|
|
67
|
+
|
|
68
|
+
get_all_repos_from_user
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'builds each repository as an OpenStruct' do
|
|
73
|
+
VCR.use_cassette('github_all_user_repos') do
|
|
74
|
+
expect(RecursiveOpenStruct).to receive(:new).exactly(29).times
|
|
75
|
+
|
|
76
|
+
get_all_repos_from_user
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -1,33 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module GitMulticast
|
|
2
|
+
describe RepositoryFetcher do
|
|
3
|
+
subject(:fetcher) { described_class }
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
let(:fetchers) { described_class::FETCHERS }
|
|
6
|
+
let(:username) { 'rranelli' }
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
describe '.get_all_repos_from_user' do
|
|
9
|
+
subject(:get_all_repos_from_user) do
|
|
10
|
+
fetcher.get_all_repos_from_user(username)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'gets repositories from all fetchers' do
|
|
14
|
+
VCR.use_cassette('repos_from_all_services') do
|
|
15
|
+
fetchers.each do |fetcher|
|
|
16
|
+
expect(fetcher).to receive(:get_all_repos_from_user)
|
|
17
|
+
.with(username).and_call_original
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
get_all_repos_from_user
|
|
21
|
+
end
|
|
22
|
+
end
|
|
7
23
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
it 'aggregates all repositories in a single list' do
|
|
25
|
+
VCR.use_cassette('repos_from_all_services') do
|
|
26
|
+
repo_names = get_all_repos_from_user.map(&:name)
|
|
27
|
+
|
|
28
|
+
expect(get_all_repos_from_user.size).to eq(32)
|
|
29
|
+
expect(repo_names).to include('git_multicast')
|
|
30
|
+
expect(repo_names).to include('CronoFaker')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
11
33
|
end
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
35
|
+
describe '.get_repo_parent' do
|
|
36
|
+
subject(:get_repo_parent) { fetcher.get_repo_parent(url) }
|
|
37
|
+
|
|
38
|
+
let(:url) do
|
|
39
|
+
'https://api.github.com/repos/rranelli/git_multicast'
|
|
16
40
|
end
|
|
17
41
|
|
|
18
|
-
|
|
42
|
+
it 'delegates to the right fetcher' do
|
|
43
|
+
VCR.use_cassette('github_repo') do
|
|
44
|
+
expect(RepositoryFetcher::Github).to receive(:get_repo)
|
|
45
|
+
.with(url).and_call_original
|
|
46
|
+
|
|
47
|
+
get_repo_parent
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'adapts with the right adapter' do
|
|
52
|
+
VCR.use_cassette('github_repo') do
|
|
53
|
+
expect(Adapters::Github).to receive_message_chain(
|
|
54
|
+
:new, :adapt, :parent
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
get_repo_parent
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'gets no parent when repo has no parent' do
|
|
62
|
+
VCR.use_cassette('github_repo') do
|
|
63
|
+
is_expected.to be_nil
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context 'when repository has a parent' do
|
|
68
|
+
let(:url) do
|
|
69
|
+
'https://api.github.com/repos/rranelli/ruby-git-hooks'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'gets the parent' do
|
|
73
|
+
VCR.use_cassette('github_repo_parent') do
|
|
74
|
+
upstream_repo_owner = get_repo_parent.owner.login
|
|
75
|
+
|
|
76
|
+
expect(upstream_repo_owner).to eq('stupied4ever')
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
19
80
|
end
|
|
20
|
-
end
|
|
21
81
|
|
|
22
|
-
|
|
23
|
-
|
|
82
|
+
describe '.get_repo' do
|
|
83
|
+
subject(:get_repo) { fetcher.get_repo(url) }
|
|
84
|
+
|
|
85
|
+
let(:url) do
|
|
86
|
+
'https://bitbucket.org/api/2.0/repositories/rranelli/cronofaker'
|
|
87
|
+
end
|
|
24
88
|
|
|
25
|
-
|
|
89
|
+
let(:bb_adapter) { double(:bb_adapter, adapt: nil) }
|
|
26
90
|
|
|
27
|
-
|
|
28
|
-
|
|
91
|
+
it 'delegates to the right fetcher' do
|
|
92
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
93
|
+
expect(RepositoryFetcher::Bitbucket).to receive(:get_repo)
|
|
94
|
+
.with(url).and_call_original
|
|
29
95
|
|
|
30
|
-
|
|
96
|
+
get_repo
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'adapts with the right adapter' do
|
|
101
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
102
|
+
expect(Adapters::Bitbucket).to receive(:new).and_return(bb_adapter)
|
|
103
|
+
expect(bb_adapter).to receive(:adapt)
|
|
104
|
+
|
|
105
|
+
get_repo
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'gets the repository' do
|
|
110
|
+
VCR.use_cassette('bitbucket_repo') do
|
|
111
|
+
expect(get_repo.name).to eq('CronoFaker')
|
|
112
|
+
end
|
|
113
|
+
end
|
|
31
114
|
end
|
|
32
115
|
end
|
|
33
116
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
require 'vcr'
|
|
2
|
+
|
|
1
3
|
require_relative '../lib/git_multicast'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
VCR.configure do |c|
|
|
6
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
7
|
+
c.hook_into :webmock
|
|
6
8
|
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.6
|
|
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-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: recursive-open-struct
|
|
@@ -80,6 +80,34 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '10.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: vcr
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
83
111
|
- !ruby/object:Gem::Dependency
|
|
84
112
|
name: pry
|
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +122,34 @@ dependencies:
|
|
|
94
122
|
- - ">="
|
|
95
123
|
- !ruby/object:Gem::Version
|
|
96
124
|
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: pry-doc
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: method_source
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
97
153
|
description:
|
|
98
154
|
email:
|
|
99
155
|
- renanranelli@gmail.com
|
|
@@ -104,6 +160,7 @@ extra_rdoc_files: []
|
|
|
104
160
|
files:
|
|
105
161
|
- ".gitignore"
|
|
106
162
|
- ".rspec"
|
|
163
|
+
- ".rubocop.yml"
|
|
107
164
|
- Gemfile
|
|
108
165
|
- Gemfile.lock
|
|
109
166
|
- LICENSE
|
|
@@ -112,25 +169,34 @@ files:
|
|
|
112
169
|
- bin/git_multicast
|
|
113
170
|
- git_multicast.gemspec
|
|
114
171
|
- lib/git_multicast.rb
|
|
115
|
-
- lib/git_multicast
|
|
116
|
-
- lib/git_multicast/
|
|
172
|
+
- lib/git_multicast/.rubocop.yml
|
|
173
|
+
- lib/git_multicast/adapters.rb
|
|
174
|
+
- lib/git_multicast/adapters/bitbucket.rb
|
|
175
|
+
- lib/git_multicast/adapters/github.rb
|
|
117
176
|
- lib/git_multicast/cli.rb
|
|
118
177
|
- lib/git_multicast/cloner.rb
|
|
119
|
-
- lib/git_multicast/github_fetcher.rb
|
|
120
178
|
- lib/git_multicast/output_formatter.rb
|
|
121
179
|
- lib/git_multicast/puller.rb
|
|
122
180
|
- lib/git_multicast/repository_fetcher.rb
|
|
181
|
+
- lib/git_multicast/repository_fetcher/bitbucket.rb
|
|
182
|
+
- lib/git_multicast/repository_fetcher/github.rb
|
|
123
183
|
- lib/git_multicast/version.rb
|
|
124
|
-
- spec/
|
|
125
|
-
- spec/
|
|
184
|
+
- spec/fixtures/vcr_cassettes/bitbucket_all_user_repos.yml
|
|
185
|
+
- spec/fixtures/vcr_cassettes/bitbucket_repo.yml
|
|
186
|
+
- spec/fixtures/vcr_cassettes/github_all_user_repos.yml
|
|
187
|
+
- spec/fixtures/vcr_cassettes/github_repo.yml
|
|
188
|
+
- spec/fixtures/vcr_cassettes/github_repo_parent.yml
|
|
189
|
+
- spec/fixtures/vcr_cassettes/repos_from_all_services.yml
|
|
190
|
+
- spec/git_multicast/adapters/bitbucket_spec.rb
|
|
126
191
|
- spec/git_multicast/cloner_spec.rb
|
|
127
|
-
- spec/git_multicast/github_fetcher_spec.rb
|
|
128
192
|
- spec/git_multicast/puller_spec.rb
|
|
193
|
+
- spec/git_multicast/repository_fetcher/bitbucket_spec.rb
|
|
194
|
+
- spec/git_multicast/repository_fetcher/github_spec.rb
|
|
129
195
|
- spec/git_multicast/repository_fetcher_spec.rb
|
|
130
196
|
- spec/spec_helper.rb
|
|
131
197
|
homepage: http://github.com/rranelli/git_multicast
|
|
132
198
|
licenses:
|
|
133
|
-
-
|
|
199
|
+
- DWTF
|
|
134
200
|
metadata: {}
|
|
135
201
|
post_install_message:
|
|
136
202
|
rdoc_options: []
|
|
@@ -153,3 +219,4 @@ signing_key:
|
|
|
153
219
|
specification_version: 4
|
|
154
220
|
summary: Execute mass actions on git repositories concurrently
|
|
155
221
|
test_files: []
|
|
222
|
+
has_rdoc:
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module GitMulticast
|
|
2
|
-
class BitbucketAdapter
|
|
3
|
-
def initialize(repo)
|
|
4
|
-
@repo = repo
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def adapt
|
|
8
|
-
make_struct(repo_hash)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
protected
|
|
12
|
-
|
|
13
|
-
attr_reader :repo
|
|
14
|
-
|
|
15
|
-
def repo_hash
|
|
16
|
-
@repo_hash ||= make_repo_hash
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def make_repo_hash
|
|
20
|
-
{
|
|
21
|
-
fork: !repo.parent.nil?,
|
|
22
|
-
ssh_url: repo.links._clone.last.href,
|
|
23
|
-
url: repo.links.self.href,
|
|
24
|
-
parent: nil,
|
|
25
|
-
name: repo.name
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def make_struct(hash)
|
|
30
|
-
RecursiveOpenStruct.new(hash, recurse_over_arrays: true)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module GitMulticast
|
|
2
|
-
class BitbucketFetcher
|
|
3
|
-
REPOS_URI = 'https://bitbucket.org/api/2.0/repositories/%{username}'
|
|
4
|
-
|
|
5
|
-
def self.get_all_repos_from_user(username)
|
|
6
|
-
uri_str = REPOS_URI % { username: username }
|
|
7
|
-
uri = URI(uri_str)
|
|
8
|
-
|
|
9
|
-
response = Net::HTTP.get_response(uri)
|
|
10
|
-
response_json = JSON.parse(response.body)
|
|
11
|
-
|
|
12
|
-
# Damn...
|
|
13
|
-
response_json['values'].each do |node|
|
|
14
|
-
node['links']['_clone'] = node['links']['clone']
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
bb_repos = response_json['values'].map { |hash| make_struct(hash) }
|
|
18
|
-
bb_repos.map { |bb_repo| BitbucketAdapter.new(bb_repo).adapt }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def self.get_repo_parent(url)
|
|
22
|
-
bb_repo = get_repo(url).parent
|
|
23
|
-
BitbucketAdapter.new(bb_repo).adapt
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def self.get_repo(url)
|
|
27
|
-
response = Net::HTTP.get_response(URI(url))
|
|
28
|
-
bb_repo = make_struct(JSON.parse(response.body))
|
|
29
|
-
BitbucketAdapter.new(bb_repo).adapt
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def self.make_struct(hash)
|
|
33
|
-
RecursiveOpenStruct.new(hash, recurse_over_arrays: true)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'recursive-open-struct'
|
|
2
|
-
require 'json'
|
|
3
|
-
|
|
4
|
-
module GitMulticast
|
|
5
|
-
class GithubFetcher
|
|
6
|
-
REPOS_URI = 'https://api.github.com/users/%{username}/repos'
|
|
7
|
-
|
|
8
|
-
def self.get_all_repos_from_user(username)
|
|
9
|
-
uri_str = REPOS_URI % { username: username }
|
|
10
|
-
uri = URI(uri_str)
|
|
11
|
-
|
|
12
|
-
response = Net::HTTP.get_response(uri)
|
|
13
|
-
repos = JSON.parse(response.body)
|
|
14
|
-
|
|
15
|
-
repos.map { |hash| make_struct(hash) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.get_repo_parent(url)
|
|
19
|
-
get_repo(url).parent
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.get_repo(url)
|
|
23
|
-
response = Net::HTTP.get_response(URI(url))
|
|
24
|
-
make_struct(JSON.parse(response.body))
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.make_struct(hash)
|
|
28
|
-
RecursiveOpenStruct.new(hash, recurse_over_arrays: true)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
describe GitMulticast::BitbucketAdapter do
|
|
2
|
-
subject(:adapter) { described_class.new(repo) }
|
|
3
|
-
|
|
4
|
-
let(:repo) { double(:repo) }
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
allow(repo).to receive_message_chain(:links, :_clone, :last, :href)
|
|
8
|
-
.and_return('git@bucketbit.org:foo/bar.git')
|
|
9
|
-
allow(repo).to receive_message_chain(:links, :self, :href)
|
|
10
|
-
.and_return('http://bucketbit.org/test-repo')
|
|
11
|
-
|
|
12
|
-
allow(repo).to receive(:name).and_return('test-repo')
|
|
13
|
-
allow(repo).to receive(:parent).and_return(nil)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '#adapt' do
|
|
17
|
-
subject(:adapt) { adapter.adapt }
|
|
18
|
-
|
|
19
|
-
it { expect(adapt.name).to eq('test-repo') }
|
|
20
|
-
it { expect(adapt.fork).to be_falsy }
|
|
21
|
-
it { expect(adapt.url).to eq('http://bucketbit.org/test-repo') }
|
|
22
|
-
it { expect(adapt.ssh_url).to eq('git@bucketbit.org:foo/bar.git') }
|
|
23
|
-
it { expect(adapt.parent).to be_nil }
|
|
24
|
-
end
|
|
25
|
-
end
|