polisher 0.6.1 → 0.7.1
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/README.md +1 -1
- data/bin/binary_gem_resolver.rb +1 -1
- data/bin/gem_dependency_checker.rb +4 -2
- data/bin/git_gem_updater.rb +3 -3
- data/bin/ruby_rpm_spec_updater.rb +2 -3
- data/lib/polisher.rb +1 -1
- data/lib/polisher/apt.rb +1 -1
- data/lib/polisher/bodhi.rb +8 -10
- data/lib/polisher/bugzilla.rb +3 -1
- data/lib/polisher/core.rb +9 -1
- data/lib/polisher/errata.rb +26 -14
- data/lib/polisher/fedora.rb +1 -1
- data/lib/polisher/formatter.rb +1 -0
- data/lib/polisher/gem.rb +124 -39
- data/lib/polisher/gem_cache.rb +34 -0
- data/lib/polisher/gemfile.rb +12 -3
- data/lib/polisher/gemspec.rb +1 -1
- data/lib/polisher/git.rb +166 -68
- data/lib/polisher/git_cache.rb +25 -0
- data/lib/polisher/koji.rb +1 -1
- data/lib/polisher/rhn.rb +1 -1
- data/lib/polisher/rpmspec.rb +263 -25
- data/lib/polisher/upstream.rb +1 -1
- data/lib/polisher/vendor.rb +1 -1
- data/lib/polisher/version.rb +2 -2
- data/lib/polisher/version_checker.rb +6 -1
- data/lib/polisher/yum.rb +1 -1
- data/spec/bodhi_spec.rb +1 -1
- data/spec/core_spec.rb +3 -3
- data/spec/errata_spec.rb +1 -1
- data/spec/fedora_spec.rb +1 -1
- data/spec/gem_spec.rb +159 -17
- data/spec/gemfile_spec.rb +2 -2
- data/spec/git_spec.rb +298 -94
- data/spec/koji_spec.rb +1 -1
- data/spec/rpmspec_spec.rb +435 -6
- data/spec/spec_helper.rb +41 -6
- data/spec/upstream_spec.rb +1 -1
- data/spec/yum_spec.rb +1 -1
- metadata +20 -3
data/lib/polisher/upstream.rb
CHANGED
data/lib/polisher/vendor.rb
CHANGED
data/lib/polisher/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.
|
1
|
+
module Polisher
|
2
|
+
VERSION = "0.7.1"
|
3
3
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Helpers to check versions
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/gem'
|
7
7
|
require 'polisher/fedora'
|
@@ -17,6 +17,7 @@ module Polisher
|
|
17
17
|
FEDORA_TARGET = :fedora
|
18
18
|
GIT_TARGET = :git
|
19
19
|
YUM_TARGET = :yum
|
20
|
+
BODHI_TARGET = :bodhi # fedora dispatches to bodhi to not enabled by default
|
20
21
|
ALL_TARGETS = [GEM_TARGET, KOJI_TARGET, FEDORA_TARGET,
|
21
22
|
GIT_TARGET, YUM_TARGET]
|
22
23
|
|
@@ -63,6 +64,10 @@ module Polisher
|
|
63
64
|
versions.merge! :yum => [Yum.version_for(name, &bl)]
|
64
65
|
end
|
65
66
|
|
67
|
+
if @check_list.include?(BODHI_TARGET)
|
68
|
+
versions.merge! :bodhi => Bodhi.versions_for(name, &bl)
|
69
|
+
end
|
70
|
+
|
66
71
|
#bodhi_version = Bodhi.versions_for(name, &bl)
|
67
72
|
#errata_version = Errata.version_for('url?', name, &bl)
|
68
73
|
|
data/lib/polisher/yum.rb
CHANGED
data/spec/bodhi_spec.rb
CHANGED
data/spec/core_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Polisher Core Extensions Specs
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'spec_helper'
|
7
7
|
require 'polisher/core'
|
@@ -52,13 +52,13 @@ describe String do
|
|
52
52
|
describe "unrpmize" do
|
53
53
|
it "returns string with rpm macros removed/replaced" do
|
54
54
|
"%doc ".unrpmize.should == ""
|
55
|
-
"%{_bindir}".unrpmize.should == "
|
55
|
+
"%{_bindir}".unrpmize.should == "bin"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "#rpmize" do
|
60
60
|
it "returns string with rpm macros swapped in" do
|
61
|
-
"
|
61
|
+
"bin".rpmize.should == "%{_bindir}"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end # describe String
|
data/spec/errata_spec.rb
CHANGED
data/spec/fedora_spec.rb
CHANGED
data/spec/gem_spec.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# Polisher Gem Specs
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
require 'spec_helper'
|
5
7
|
|
6
8
|
require 'polisher/gem'
|
7
9
|
|
8
10
|
module Polisher
|
9
11
|
describe Gem do
|
10
12
|
describe "#initialize" do
|
11
|
-
it "sets
|
13
|
+
it "sets gem attributes" do
|
12
14
|
gem = Polisher::Gem.new :name => 'rails',
|
13
15
|
:version => '4.0.0',
|
14
16
|
:deps => ['activesupport', 'activerecord'],
|
@@ -20,6 +22,27 @@ module Polisher
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
25
|
+
describe "#ignorable_file?" do
|
26
|
+
context "args matches an ignorable file" do
|
27
|
+
it "returns true" do
|
28
|
+
Polisher::Gem.ignorable_file?('foo.gemspec').should be_true
|
29
|
+
Polisher::Gem.ignorable_file?('Gemfile').should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "args does not match an ignorable file" do
|
34
|
+
it "returns false" do
|
35
|
+
Polisher::Gem.ignorable_file?('.rvmra').should be_false
|
36
|
+
Polisher::Gem.ignorable_file?('foo.gemspoc').should be_false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#local_versions_for" do
|
42
|
+
it "returns versions of specified gem in local db"
|
43
|
+
it "invokes cb with versions retrieved"
|
44
|
+
end
|
45
|
+
|
23
46
|
describe "#parse" do
|
24
47
|
it "returns new gem" do
|
25
48
|
gem = Polisher::Gem.parse
|
@@ -47,20 +70,68 @@ module Polisher
|
|
47
70
|
end
|
48
71
|
end
|
49
72
|
|
50
|
-
describe "#retrieve" do
|
51
|
-
before(:each) do
|
52
|
-
@local_gem = Polisher::Test::LOCAL_GEM
|
53
73
|
|
54
|
-
|
55
|
-
|
56
|
-
|
74
|
+
describe "#download_gem" do
|
75
|
+
context "gem in GemCache" do
|
76
|
+
it "returns GemCache gem"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "uses curl to download gem"
|
80
|
+
it "sets gem in gem cached"
|
81
|
+
it "returns downloaded gem binary contents"
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#download_gem_path" do
|
85
|
+
it "downloads gem" do
|
86
|
+
gem = Polisher::Gem.new
|
87
|
+
gem.should_receive(:download_gem)
|
88
|
+
gem.downloaded_gem_path
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns gem cache path for gem" do
|
92
|
+
# stub out d/l
|
93
|
+
gem = Polisher::Gem.new :name => 'rails', :version => '1.0'
|
94
|
+
gem.should_receive(:download_gem)
|
95
|
+
Polisher::GemCache.should_receive(:path_for).
|
96
|
+
with('rails', '1.0').
|
97
|
+
at_least(:once).
|
98
|
+
and_return('rails_path')
|
99
|
+
gem.downloaded_gem_path.should == 'rails_path'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#gem_path" do
|
104
|
+
it "returns specified path" do
|
105
|
+
gem = Polisher::Gem.new :path => 'gem_path'
|
106
|
+
gem.gem_path.should == 'gem_path'
|
107
|
+
end
|
57
108
|
|
58
|
-
|
59
|
-
|
109
|
+
context "specified path is null" do
|
110
|
+
it "returns downloaded gem path" do
|
111
|
+
gem = Polisher::Gem.new
|
112
|
+
gem.should_receive(:downloaded_gem_path).and_return('gem_path')
|
113
|
+
gem.gem_path.should == 'gem_path'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
60
117
|
|
61
|
-
|
62
|
-
|
63
|
-
|
118
|
+
describe "#unpack" do
|
119
|
+
it "unpacks gem at gem_path into temp dir"
|
120
|
+
it "returns tmp dir"
|
121
|
+
context "block specified" do
|
122
|
+
it "invokes block with tmp dir"
|
123
|
+
it "removes tmp dir"
|
124
|
+
it "returns nil"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#file_paths" do
|
129
|
+
it "returns list of file paths in gem"
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#retrieve" do
|
133
|
+
before(:each) do
|
134
|
+
@local_gem = Polisher::Test::LOCAL_GEM
|
64
135
|
end
|
65
136
|
|
66
137
|
it "returns gem retrieved from rubygems" do
|
@@ -71,12 +142,83 @@ module Polisher
|
|
71
142
|
gem.deps.should == @local_gem[:deps]
|
72
143
|
gem.dev_deps.should == @local_gem[:dev_deps]
|
73
144
|
end
|
145
|
+
end
|
74
146
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
147
|
+
describe "#versions" do
|
148
|
+
it "looks up and returns versions for gemname in polisher version checker"
|
149
|
+
|
150
|
+
context "recursive is true" do
|
151
|
+
it "appends versions of gem dependencies to versions list"
|
152
|
+
context "dev_deps is true" do
|
153
|
+
it "appends versions of gem dev dependencies to versions list"
|
154
|
+
end
|
79
155
|
end
|
80
156
|
end
|
157
|
+
|
158
|
+
describe "#vendored_file_paths" do
|
159
|
+
it "returns file marks in gem marked as vendored" do
|
160
|
+
expected = [ 'vendor/foo.rb', 'vendor/bar/foo.rb']
|
161
|
+
paths = ['foo.rb'] + expected
|
162
|
+
gem = Polisher::Gem.new
|
163
|
+
gem.should_receive(:file_paths).and_return(paths)
|
164
|
+
gem.vendored_file_paths.should == expected
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "#vendored" do
|
169
|
+
it "returns list of vendored modules in gem" do
|
170
|
+
gem = Polisher::Gem.new
|
171
|
+
vendored = ['vendor/thor.rb', 'vendor/thor/foo.rb', 'vendor/biz/baz.rb']
|
172
|
+
gem.should_receive(:vendored_file_paths).and_return(vendored)
|
173
|
+
gem.vendored.should == {'thor' => nil, 'biz' => nil}
|
174
|
+
end
|
175
|
+
|
176
|
+
context "vendored module has VERSION.rb file" do
|
177
|
+
it "returns version of vendored gems"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe "#diff" do
|
182
|
+
before(:each) do
|
183
|
+
@gem1 = Polisher::Gem.new
|
184
|
+
@gem2 = Polisher::Gem.new
|
185
|
+
|
186
|
+
@result = AwesomeSpawn::CommandResult.new '', 'diff_out', '', 0
|
187
|
+
end
|
188
|
+
|
189
|
+
it "runs diff against unpacked local and other gems and returns output" do
|
190
|
+
@gem1.should_receive(:unpack).and_return('dir1')
|
191
|
+
@gem2.should_receive(:unpack).and_return('dir2')
|
192
|
+
AwesomeSpawn.should_receive(:run).
|
193
|
+
with("#{Polisher::Gem::DIFF_CMD} -r dir1 dir2").
|
194
|
+
and_return(@result)
|
195
|
+
@gem1.diff(@gem2).should == @result.output
|
196
|
+
end
|
197
|
+
|
198
|
+
it "removes unpacked gem dirs" do
|
199
|
+
@gem1.should_receive(:unpack).and_return('dir1')
|
200
|
+
@gem2.should_receive(:unpack).and_return('dir2')
|
201
|
+
AwesomeSpawn.should_receive(:run).and_return(@result)
|
202
|
+
FileUtils.should_receive(:rm_rf).with('dir1')
|
203
|
+
FileUtils.should_receive(:rm_rf).with('dir2')
|
204
|
+
# XXX for the GemCache dir cleaning:
|
205
|
+
FileUtils.should_receive(:rm_rf).at_least(:once)
|
206
|
+
@gem1.diff(@gem2)
|
207
|
+
end
|
208
|
+
|
209
|
+
context "error during operations" do
|
210
|
+
it "removes unpacked gem dirs" do
|
211
|
+
@gem1.should_receive(:unpack).and_return('dir1')
|
212
|
+
@gem2.should_receive(:unpack).and_return('dir2')
|
213
|
+
AwesomeSpawn.should_receive(:run).
|
214
|
+
and_raise(AwesomeSpawn::CommandResultError.new('', ''))
|
215
|
+
FileUtils.should_receive(:rm_rf).with('dir1')
|
216
|
+
FileUtils.should_receive(:rm_rf).with('dir2')
|
217
|
+
FileUtils.should_receive(:rm_rf).at_least(:once)
|
218
|
+
@gem1.diff(@gem2)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
81
223
|
end # describe Gem
|
82
224
|
end # module Polisher
|
data/spec/gemfile_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Polisher Gemfile Specs
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/gemfile'
|
7
7
|
|
@@ -23,7 +23,7 @@ module Polisher
|
|
23
23
|
it "sets default gemfile version,files" do
|
24
24
|
gemfile = Polisher::Gemfile.new
|
25
25
|
gemfile.version.should be_nil
|
26
|
-
gemfile.
|
26
|
+
gemfile.file_paths.should == []
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/spec/git_spec.rb
CHANGED
@@ -1,172 +1,376 @@
|
|
1
1
|
# Polisher Git Spec
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/git'
|
7
7
|
|
8
8
|
module Polisher
|
9
|
+
describe GitRepo do
|
10
|
+
describe "#initialize" do
|
11
|
+
it "initializes url" do
|
12
|
+
repo = described_class.new :url => 'repo_url'
|
13
|
+
repo.url.should == 'repo_url'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#path" do
|
18
|
+
it "returns git cache path for url" do
|
19
|
+
repo = described_class.new :url => 'repo_url'
|
20
|
+
Polisher::GitCache.should_receive(:path_for).
|
21
|
+
with('repo_url').
|
22
|
+
and_return('repo_path')
|
23
|
+
repo.path.should == 'repo_path'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#clone" do
|
28
|
+
it "runs git clone" do
|
29
|
+
expected = "/usr/bin/git clone repo_url repo_path"
|
30
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
31
|
+
|
32
|
+
repo = described_class.new :url => 'repo_url'
|
33
|
+
repo.should_receive(:path).and_return('repo_path')
|
34
|
+
repo.clone
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#cloned?" do
|
39
|
+
before(:each) do
|
40
|
+
@repo = described_class.new
|
41
|
+
@repo.should_receive(:path).and_return('repo_path')
|
42
|
+
end
|
43
|
+
|
44
|
+
context "repo path directory exists" do
|
45
|
+
it "returns true" do
|
46
|
+
File.should_receive(:directory?).with('repo_path').and_return(true)
|
47
|
+
@repo.should be_cloned
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "repo path directory does not exist" do
|
52
|
+
it "returns false" do
|
53
|
+
File.should_receive(:directory?).with('repo_path').and_return(false)
|
54
|
+
@repo.should_not be_cloned
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#in_repo" do
|
60
|
+
it "chdir to repo path, invokes block, restores dir" do
|
61
|
+
repo = described_class.new
|
62
|
+
Dir.mktmpdir do |dir|
|
63
|
+
repo.should_receive(:path).and_return(dir)
|
64
|
+
invoked = false
|
65
|
+
orig = Dir.pwd
|
66
|
+
repo.in_repo do
|
67
|
+
Dir.pwd.should == dir
|
68
|
+
invoked = true
|
69
|
+
end
|
70
|
+
Dir.pwd.should == orig
|
71
|
+
invoked.should be_true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#reset!" do
|
77
|
+
it "resets git repo to head" do
|
78
|
+
expected = "/usr/bin/git reset HEAD~ --hard"
|
79
|
+
repo = described_class.new
|
80
|
+
repo.should_receive(:in_repo).and_yield
|
81
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
82
|
+
repo.reset!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#pull" do
|
87
|
+
it "git pulls" do
|
88
|
+
expected = "/usr/bin/git pull"
|
89
|
+
repo = described_class.new
|
90
|
+
repo.should_receive(:in_repo).and_yield
|
91
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
92
|
+
repo.pull
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#checkout" do
|
97
|
+
it "git checks out target" do
|
98
|
+
expected = "/usr/bin/git checkout master"
|
99
|
+
repo = described_class.new
|
100
|
+
repo.should_receive(:in_repo).and_yield
|
101
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
102
|
+
repo.checkout('master')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#commit" do
|
107
|
+
it "git commits with message" do
|
108
|
+
expected = "/usr/bin/git commit -m 'msg'"
|
109
|
+
repo = described_class.new
|
110
|
+
repo.should_receive(:in_repo).and_yield
|
111
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
112
|
+
repo.commit('msg')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
9
117
|
describe GitPackage do
|
118
|
+
describe "#initialize" do
|
119
|
+
it "initializes name" do
|
120
|
+
pkg = described_class.new :name => 'pkg_name'
|
121
|
+
pkg.name.should == 'pkg_name'
|
122
|
+
end
|
123
|
+
|
124
|
+
it "initializes version" do
|
125
|
+
pkg = described_class.new :version => 'pkg_version'
|
126
|
+
pkg.version.should == 'pkg_version'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
10
130
|
describe "#rpm_name" do
|
11
131
|
it "returns rubygem-gem_name" do
|
12
|
-
pkg =
|
132
|
+
pkg = described_class.new :name => 'rails'
|
13
133
|
pkg.rpm_name.should == 'rubygem-rails'
|
14
134
|
end
|
15
135
|
end
|
16
136
|
|
17
137
|
describe "#srpm" do
|
18
138
|
it "returns name of srpm" do
|
19
|
-
pkg =
|
139
|
+
pkg = described_class.new :name => 'rails', :version => '1.0.0'
|
20
140
|
pkg.srpm.should == 'rubygem-rails-1.0.0-1.*.src.rpm'
|
21
141
|
end
|
22
142
|
end
|
23
143
|
|
144
|
+
describe "#spec_file" do
|
145
|
+
it "returns name of spec file" do
|
146
|
+
pkg = described_class.new :name => 'rails'
|
147
|
+
pkg.spec_file.should == 'rubygem-rails.spec'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
24
151
|
describe "#spec" do
|
25
|
-
it "returns
|
26
|
-
|
27
|
-
|
152
|
+
it "returns handle to parsed Polisher::RPMSpec"
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#pkg_files" do
|
156
|
+
it "returns spec, .gitignore, sources"
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#path" do
|
160
|
+
it "returns Git Cache path for rpm name"
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#git_clone" do
|
164
|
+
it "is an alias for superclass#clone"
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#clone" do
|
168
|
+
it "clones package" do
|
169
|
+
# stub out glob / rm_rf
|
170
|
+
Dir.should_receive(:glob).and_return([])
|
171
|
+
FileUtils.should_receive(:rm_rf).at_least(:once)
|
172
|
+
|
173
|
+
pkg = described_class.new :name => 'rails'
|
174
|
+
pkg.should_receive(:in_repo).and_yield
|
175
|
+
|
176
|
+
expected = '/usr/bin/fedpkg clone rubygem-rails'
|
177
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
178
|
+
pkg.clone
|
28
179
|
end
|
180
|
+
|
181
|
+
it "moves files from pkg subdir to current dir"
|
182
|
+
it "rm's pkg subdir"
|
29
183
|
end
|
30
184
|
|
31
|
-
describe "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
185
|
+
describe "#dead?" do
|
186
|
+
before(:each) do
|
187
|
+
@pkg = described_class.new
|
188
|
+
@pkg.should_receive(:in_repo).and_yield
|
189
|
+
end
|
190
|
+
|
191
|
+
context "dead.package exists" do
|
192
|
+
it "returns true" do
|
193
|
+
File.should_receive(:exists?).with('dead.package').and_return(true)
|
194
|
+
@pkg.should be_dead
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "dead.package does not exist" do
|
199
|
+
it "returns false" do
|
200
|
+
File.should_receive(:exists?).with('dead.package').and_return(false)
|
201
|
+
@pkg.should_not be_dead
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe "#fetch" do
|
207
|
+
before(:each) do
|
208
|
+
@pkg = described_class.new
|
209
|
+
end
|
210
|
+
|
211
|
+
context "pkg not cloned" do
|
212
|
+
it "clones package" do
|
213
|
+
@pkg.should_receive(:dead?).and_return(false)
|
214
|
+
@pkg.should_receive(:reset!)
|
215
|
+
@pkg.should_receive(:checkout)
|
216
|
+
@pkg.should_receive(:pull)
|
217
|
+
|
218
|
+
@pkg.should_receive(:cloned?).and_return(false)
|
219
|
+
@pkg.should_receive(:clone)
|
220
|
+
@pkg.fetch
|
39
221
|
end
|
40
222
|
end
|
41
223
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
224
|
+
context "pkg cloned" do
|
225
|
+
it "does not clone pkg" do
|
226
|
+
@pkg.should_receive(:dead?).and_return(false)
|
227
|
+
@pkg.should_receive(:reset!)
|
228
|
+
@pkg.should_receive(:checkout)
|
229
|
+
@pkg.should_receive(:pull)
|
230
|
+
|
231
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
232
|
+
@pkg.should_not_receive(:clone)
|
233
|
+
@pkg.fetch
|
234
|
+
end
|
47
235
|
end
|
48
236
|
|
49
|
-
context "dead
|
237
|
+
context "pkg dead" do
|
50
238
|
it "raises Exception" do
|
51
|
-
|
52
|
-
|
53
|
-
File.should_receive(:exists?).with('dead.package').and_return(true)
|
239
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
240
|
+
@pkg.should_receive(:dead?).and_return(true)
|
54
241
|
lambda{
|
55
|
-
|
242
|
+
@pkg.fetch
|
56
243
|
}.should raise_error(Exception)
|
57
244
|
end
|
58
245
|
end
|
59
246
|
|
60
|
-
it "checks out master
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
described_class.clone "rails"
|
66
|
-
end
|
247
|
+
it "checks out master" do
|
248
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
249
|
+
@pkg.should_receive(:dead?).and_return(false)
|
250
|
+
@pkg.should_receive(:reset!)
|
251
|
+
@pkg.should_receive(:pull)
|
67
252
|
|
68
|
-
|
69
|
-
|
70
|
-
Dir.should_receive(:chdir).with('rubygem-rails')
|
71
|
-
AwesomeSpawn.should_receive(:run).with("/usr/bin/git reset HEAD~ --hard")
|
72
|
-
AwesomeSpawn.should_receive(:run).at_least(2).times # stub out calls to run
|
73
|
-
described_class.clone "rails"
|
253
|
+
@pkg.should_receive(:checkout).with('master')
|
254
|
+
@pkg.fetch
|
74
255
|
end
|
75
256
|
|
76
|
-
it "
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
257
|
+
it "resets HEAD" do
|
258
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
259
|
+
@pkg.should_receive(:dead?).and_return(false)
|
260
|
+
@pkg.should_receive(:checkout)
|
261
|
+
@pkg.should_receive(:pull)
|
262
|
+
|
263
|
+
@pkg.should_receive(:reset!)
|
264
|
+
@pkg.fetch
|
82
265
|
end
|
83
266
|
|
84
|
-
it "
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
pkg
|
89
|
-
|
90
|
-
|
267
|
+
it "pulls repo" do
|
268
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
269
|
+
@pkg.should_receive(:dead?).and_return(false)
|
270
|
+
@pkg.should_receive(:reset!)
|
271
|
+
@pkg.should_receive(:checkout)
|
272
|
+
|
273
|
+
|
274
|
+
@pkg.should_receive(:pull)
|
275
|
+
@pkg.fetch
|
91
276
|
end
|
92
277
|
end
|
93
278
|
|
279
|
+
describe "#update_spec_to" do
|
280
|
+
it "updates spec version"
|
281
|
+
it "updates spec release"
|
282
|
+
end
|
283
|
+
|
284
|
+
describe "#gen_sources_for" do
|
285
|
+
it "writes gem md5sum to sources file"
|
286
|
+
end
|
287
|
+
|
288
|
+
describe "#ignore" do
|
289
|
+
it "adds gem to .gitignore file"
|
290
|
+
end
|
291
|
+
|
94
292
|
describe "#update_to" do
|
95
293
|
it "updates rpm spec"
|
96
|
-
it "
|
97
|
-
it "
|
294
|
+
it "generates new sources file"
|
295
|
+
it "ignores gem"
|
98
296
|
end
|
99
297
|
|
100
|
-
describe "#
|
101
|
-
it "
|
102
|
-
|
298
|
+
describe "#commit" do
|
299
|
+
it "git adds the pkg_files" do
|
300
|
+
pkg = described_class.new(:name => 'rails')
|
301
|
+
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
302
|
+
pkg.should_receive(:pkg_files).and_return(['pkg_files'])
|
303
|
+
expected = "/usr/bin/git add pkg_files"
|
304
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
103
305
|
AwesomeSpawn.should_receive(:run).at_least(:once)
|
104
|
-
|
306
|
+
pkg.commit
|
105
307
|
end
|
106
308
|
|
107
|
-
it "
|
108
|
-
|
309
|
+
it "commits the package with default msg" do
|
310
|
+
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
311
|
+
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
312
|
+
expected = "/usr/bin/git commit -m 'updated to 1.0.0'"
|
313
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
109
314
|
AwesomeSpawn.should_receive(:run).at_least(:once)
|
110
|
-
|
315
|
+
pkg.commit
|
111
316
|
end
|
112
317
|
end
|
113
318
|
|
114
|
-
describe "#
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
context "package spec does not have a %check section" do
|
123
|
-
it "returns false" do
|
124
|
-
File.should_receive(:open).with("rubygem-rails.spec", "r").and_yield("")
|
125
|
-
described_class.new(:name => "rails").has_check?.should be_false
|
126
|
-
end
|
319
|
+
describe "#build_srpm" do
|
320
|
+
it "uses package command to build srpm" do
|
321
|
+
pkg = described_class.new
|
322
|
+
pkg.should_receive(:in_repo).and_yield
|
323
|
+
AwesomeSpawn.should_receive(:run).with("/usr/bin/fedpkg srpm")
|
324
|
+
pkg.build_srpm
|
127
325
|
end
|
128
326
|
end
|
129
327
|
|
130
|
-
describe "#
|
131
|
-
it "
|
132
|
-
|
133
|
-
|
134
|
-
|
328
|
+
describe "#scratch_build" do
|
329
|
+
it "uses build command to build srpm" do
|
330
|
+
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
331
|
+
pkg.should_receive(:in_repo).and_yield
|
332
|
+
expected = "/usr/bin/koji build --scratch rawhide rubygem-rails-1.0.0-1.*.src.rpm"
|
333
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
334
|
+
pkg.scratch_build
|
135
335
|
end
|
336
|
+
end
|
136
337
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
338
|
+
describe "#build" do
|
339
|
+
it "builds srpm and runs scratch build" do
|
340
|
+
pkg = described_class.new
|
341
|
+
pkg.should_receive(:build_srpm)
|
342
|
+
pkg.should_receive(:scratch_build)
|
343
|
+
pkg.build
|
141
344
|
end
|
142
345
|
end
|
143
346
|
|
144
347
|
describe "#version_for" do
|
145
348
|
it "uses git to retrieve the package" do
|
146
|
-
|
349
|
+
pkg = "#{described_class::DIST_GIT_URL}rubygem-rails.git"
|
350
|
+
dir = Polisher::GitCache.path_for('rubygem-rails')
|
351
|
+
expected = "/usr/bin/git clone #{pkg} #{dir}"
|
352
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
147
353
|
described_class.version_for 'rails'
|
148
354
|
end
|
149
355
|
|
150
|
-
it "
|
356
|
+
it "returns version of the package" do
|
151
357
|
AwesomeSpawn.should_receive(:run) # stub out run
|
152
|
-
File.should_receive(:read).with("rubygem-rails.spec").and_return("contents")
|
153
|
-
Polisher::RPMSpec.should_receive(:parse).with("contents").and_return(Polisher::RPMSpec.new)
|
154
|
-
described_class.version_for 'rails'
|
155
|
-
end
|
156
358
|
|
157
|
-
it "returns version of the package" do
|
158
359
|
spec = Polisher::RPMSpec.new :version => '1.0.0'
|
159
|
-
|
160
|
-
|
161
|
-
|
360
|
+
pkg = described_class.new
|
361
|
+
described_class.should_receive(:new).and_return(pkg)
|
362
|
+
pkg.should_receive(:spec).and_return(spec)
|
363
|
+
|
162
364
|
described_class.version_for('rails').should == '1.0.0'
|
163
365
|
end
|
164
366
|
|
165
367
|
it "invokes callback with version of package" do
|
166
|
-
spec = Polisher::RPMSpec.new :version => '1.0.0'
|
167
368
|
AwesomeSpawn.should_receive(:run) # stub out run
|
168
|
-
|
169
|
-
Polisher::RPMSpec.
|
369
|
+
|
370
|
+
spec = Polisher::RPMSpec.new :version => '1.0.0'
|
371
|
+
pkg = described_class.new
|
372
|
+
described_class.should_receive(:new).and_return(pkg)
|
373
|
+
pkg.should_receive(:spec).and_return(spec)
|
170
374
|
|
171
375
|
cb = proc {}
|
172
376
|
cb.should_receive(:call).with(:git, 'rails', ['1.0.0'])
|