polisher 0.10.2 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/binary_gem_resolver.rb +2 -2
- data/bin/bundler2yum.rb +51 -0
- data/bin/check_ruby_spec.rb +32 -0
- data/bin/gem_dependency_checker.rb +13 -242
- data/bin/gem_mapper.rb +27 -0
- data/bin/gems2update.rb +27 -0
- data/bin/git_gem_diff.rb +48 -0
- data/bin/git_gem_updater.rb +3 -3
- data/bin/missing_deps.rb +29 -0
- data/bin/polisher-config.rb +17 -0
- data/bin/ruby_rpm_spec_updater.rb +23 -2
- data/lib/polisher.rb +5 -12
- data/lib/polisher/adaptors/checker_loader.rb +78 -0
- data/lib/polisher/{upstream.rb → adaptors/upstream.rb} +1 -0
- data/lib/polisher/adaptors/version_checker.rb +57 -0
- data/lib/polisher/adaptors/version_checker/bodhi.rb +29 -0
- data/lib/polisher/adaptors/version_checker/errata.rb +29 -0
- data/lib/polisher/adaptors/version_checker/fedora.rb +29 -0
- data/lib/polisher/adaptors/version_checker/gem.rb +27 -0
- data/lib/polisher/adaptors/version_checker/git.rb +29 -0
- data/lib/polisher/adaptors/version_checker/koji.rb +29 -0
- data/lib/polisher/adaptors/version_checker/yum.rb +29 -0
- data/lib/polisher/cli/all.rb +22 -0
- data/lib/polisher/cli/bin/gem_dependency_checker.rb +85 -0
- data/lib/polisher/cli/bin/gem_mapper.rb +37 -0
- data/lib/polisher/cli/bin/gems2update.rb +86 -0
- data/lib/polisher/cli/bin/missing_deps.rb +35 -0
- data/lib/polisher/cli/conf.rb +18 -0
- data/lib/polisher/cli/default.rb +25 -0
- data/lib/polisher/cli/format.rb +130 -0
- data/lib/polisher/cli/sources.rb +106 -0
- data/lib/polisher/cli/specifier.rb +30 -0
- data/lib/polisher/cli/status.rb +50 -0
- data/lib/polisher/cli/targets.rb +88 -0
- data/lib/polisher/gem.rb +41 -338
- data/lib/polisher/gem/attributes.rb +20 -0
- data/lib/polisher/gem/dependencies.rb +63 -0
- data/lib/polisher/gem/diff.rb +39 -0
- data/lib/polisher/gem/files.rb +111 -0
- data/lib/polisher/gem/parser.rb +85 -0
- data/lib/polisher/gem/retriever.rb +137 -0
- data/lib/polisher/{gem_state.rb → gem/state.rb} +6 -6
- data/lib/polisher/gem/versions.rb +131 -0
- data/lib/polisher/gemfile.rb +20 -89
- data/lib/polisher/gemfile/attributes.rb +19 -0
- data/lib/polisher/gemfile/deps.rb +43 -0
- data/lib/polisher/gemfile/parser.rb +45 -0
- data/lib/polisher/git/pkg.rb +33 -238
- data/lib/polisher/git/pkg/attributes.rb +60 -0
- data/lib/polisher/git/pkg/builder.rb +47 -0
- data/lib/polisher/git/pkg/repo.rb +82 -0
- data/lib/polisher/git/pkg/updater.rb +53 -0
- data/lib/polisher/git/pkg/versions.rb +40 -0
- data/lib/polisher/git/project.rb +1 -1
- data/lib/polisher/git/repo.rb +79 -76
- data/lib/polisher/{vendor.rb → mixins/vendored_deps.rb} +4 -7
- data/lib/polisher/mixins/versioned_dependencies.rb +86 -0
- data/lib/polisher/record.rb +2 -0
- data/lib/polisher/rpm.rb +23 -0
- data/lib/polisher/rpm/patch.rb +10 -8
- data/lib/polisher/rpm/requirement.rb +33 -189
- data/lib/polisher/rpm/requirement/attributes.rb +43 -0
- data/lib/polisher/rpm/requirement/comparison.rb +97 -0
- data/lib/polisher/rpm/requirement/gem_reference.rb +46 -0
- data/lib/polisher/rpm/requirement/parser.rb +41 -0
- data/lib/polisher/rpm/spec.rb +97 -436
- data/lib/polisher/rpm/spec/check.rb +14 -0
- data/lib/polisher/rpm/spec/comparison.rb +64 -0
- data/lib/polisher/rpm/spec/files.rb +15 -0
- data/lib/polisher/rpm/spec/gem_files.rb +65 -0
- data/lib/polisher/rpm/spec/gem_reference.rb +59 -0
- data/lib/polisher/rpm/spec/gem_requirements.rb +73 -0
- data/lib/polisher/rpm/spec/parser.rb +106 -0
- data/lib/polisher/rpm/spec/requirements.rb +31 -0
- data/lib/polisher/rpm/spec/subpackages.rb +23 -0
- data/lib/polisher/rpm/spec/updater.rb +268 -0
- data/lib/polisher/specifier.rb +13 -0
- data/lib/polisher/targets.rb +36 -0
- data/lib/polisher/{apt.rb → targets/apt.rb} +1 -1
- data/lib/polisher/targets/bodhi.rb +43 -0
- data/lib/polisher/{bugzilla.rb → targets/bugzilla.rb} +1 -1
- data/lib/polisher/targets/errata.rb +55 -0
- data/lib/polisher/targets/errata/build.rb +24 -0
- data/lib/polisher/targets/fedora.rb +47 -0
- data/lib/polisher/targets/koji.rb +39 -0
- data/lib/polisher/targets/koji/builder.rb +38 -0
- data/lib/polisher/targets/koji/diff.rb +39 -0
- data/lib/polisher/targets/koji/rpc.rb +43 -0
- data/lib/polisher/targets/koji/versions.rb +67 -0
- data/lib/polisher/targets/rhn.rb +12 -0
- data/lib/polisher/targets/yum.rb +36 -0
- data/lib/polisher/{component.rb → util/component.rb} +3 -3
- data/lib/polisher/util/conf_helpers.rb +77 -0
- data/lib/polisher/util/config.rb +45 -0
- data/lib/polisher/util/core_ext.rb +59 -0
- data/lib/polisher/{error.rb → util/error.rb} +0 -0
- data/lib/polisher/{gem_cache.rb → util/gem_cache.rb} +1 -1
- data/lib/polisher/{git_cache.rb → util/git_cache.rb} +0 -0
- data/lib/polisher/{logger.rb → util/logger.rb} +2 -0
- data/lib/polisher/{tag_mapper.rb → util/tag_mapper.rb} +1 -1
- data/lib/polisher/version.rb +1 -1
- data/spec/{upstream_spec.rb → adaptors/upstream_spec.rb} +1 -1
- data/spec/{version_checker_spec.rb → adaptors/version_checker_spec.rb} +1 -6
- data/spec/data/activesupport-4.1.4.gem +0 -0
- data/spec/data/rubygem-activesupport-with-doc.spec +247 -0
- data/spec/data/rubygem-activesupport-without-requires.spec +232 -0
- data/spec/data/rubygem-activesupport.spec +0 -122
- data/spec/fixtures/gem_json.rb +49 -0
- data/spec/fixtures/gem_spec.rb +13 -0
- data/spec/fixtures/gemfile.rb +10 -0
- data/spec/fixtures/local_gem.rb +62 -0
- data/spec/fixtures/rpm_spec.rb +91 -0
- data/spec/gem/attributes_spec.rb +17 -0
- data/spec/gem/diff_spec.rb +80 -0
- data/spec/gem/files_spec.rb +171 -0
- data/spec/gem/parser_spec.rb +44 -0
- data/spec/gem/retriever_spec.rb +124 -0
- data/spec/gem/state_spec.rb +79 -0
- data/spec/gem/versions_spec.rb +148 -0
- data/spec/gem_spec.rb +5 -347
- data/spec/gemfile/deps_spec.rb +20 -0
- data/spec/gemfile/parser_spec.rb +26 -0
- data/spec/gemfile_spec.rb +0 -34
- data/spec/git/pkg/attributes_spec.rb +128 -0
- data/spec/git/pkg/builder_spec.rb +63 -0
- data/spec/git/pkg/repo_spec.rb +146 -0
- data/spec/git/pkg/updater_spec.rb +86 -0
- data/spec/git/pkg/versions_spec.rb +42 -0
- data/spec/git/pkg_spec.rb +21 -0
- data/spec/git/project_spec.rb +21 -0
- data/spec/git/repo_spec.rb +160 -0
- data/spec/{vendor_spec.rb → mixins/vendored_deps_spec.rb} +2 -4
- data/spec/mixins/versioned_dependencies_spec.rb +48 -0
- data/spec/rpm/patch_spec.rb +48 -0
- data/spec/rpm/requirement/attributes_spec.rb +34 -0
- data/spec/rpm/requirement/comparison_spec.rb +286 -0
- data/spec/rpm/requirement/gem_spec.rb +49 -0
- data/spec/rpm/requirement/parser_spec.rb +31 -0
- data/spec/rpm/requirement_spec.rb +8 -334
- data/spec/rpm/spec/check_spec.rb +25 -0
- data/spec/rpm/spec/comparison_spec.rb +55 -0
- data/spec/rpm/spec/files_spec.rb +17 -0
- data/spec/rpm/spec/gem_files_spec.rb +112 -0
- data/spec/rpm/spec/gem_reference_spec.rb +99 -0
- data/spec/rpm/spec/gem_requirement_spec.rb +38 -0
- data/spec/rpm/spec/parser_spec.rb +64 -0
- data/spec/rpm/spec/requirements_spec.rb +10 -0
- data/spec/rpm/spec/subpackages_spec.rb +38 -0
- data/spec/rpm/spec/updater_spec.rb +486 -0
- data/spec/rpm/spec_spec.rb +27 -174
- data/spec/spec_helper.rb +7 -107
- data/spec/support/coveralls.rb +10 -0
- data/spec/support/fixtures.rb +8 -0
- data/spec/support/paths.rb +20 -0
- data/spec/support/rspec.rb +20 -0
- data/spec/support/vcr.rb +11 -0
- data/spec/{bodhi_spec.rb → targets/bodhi_spec.rb} +3 -1
- data/spec/{errata_spec.rb → targets/errata_spec.rb} +2 -2
- data/spec/{fedora_spec.rb → targets/fedora_spec.rb} +3 -3
- data/spec/targets/koji/builder_spec.rb +48 -0
- data/spec/targets/koji/diff_spec.rb +36 -0
- data/spec/targets/koji/rpc_spec.rb +28 -0
- data/spec/{koji_spec.rb → targets/koji/versions_spec.rb} +1 -59
- data/spec/targets/koji_spec.rb +11 -0
- data/spec/{yum_spec.rb → targets/yum_spec.rb} +1 -1
- data/spec/{component_spec.rb → util/component_spec.rb} +1 -1
- data/spec/{core_spec.rb → util/core_ext_spec.rb} +2 -3
- metadata +278 -88
- data/lib/polisher/bodhi.rb +0 -23
- data/lib/polisher/config.rb +0 -32
- data/lib/polisher/core.rb +0 -101
- data/lib/polisher/errata.rb +0 -75
- data/lib/polisher/fedora.rb +0 -46
- data/lib/polisher/git.rb +0 -8
- data/lib/polisher/koji.rb +0 -159
- data/lib/polisher/rhn.rb +0 -15
- data/lib/polisher/version_checker.rb +0 -177
- data/lib/polisher/yum.rb +0 -37
- data/spec/git_spec.rb +0 -445
@@ -0,0 +1,128 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the MIT license
|
3
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
+
|
5
|
+
require 'polisher/git/pkg'
|
6
|
+
|
7
|
+
module Polisher
|
8
|
+
describe Git::Pkg do
|
9
|
+
describe "#rpm_name" do
|
10
|
+
it "returns rubygem-gem_name" do
|
11
|
+
pkg = described_class.new :name => 'rails'
|
12
|
+
pkg.rpm_name.should == 'rubygem-rails'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#srpm" do
|
17
|
+
it "returns name of srpm" do
|
18
|
+
pkg = described_class.new :name => 'rails', :version => '1.0.0'
|
19
|
+
pkg.srpm.should == 'rubygem-rails-1.0.0-1.*.src.rpm'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#spec_file" do
|
24
|
+
it "returns name of spec file" do
|
25
|
+
pkg = described_class.new :name => 'rails'
|
26
|
+
pkg.spec_file.should == 'rubygem-rails.spec'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#spec?" do
|
31
|
+
context "repo includes spec file" do
|
32
|
+
it "returns true" do
|
33
|
+
pkg = described_class.new :name => 'rails'
|
34
|
+
pkg.should_receive(:include?).with(pkg.spec_file).and_return(true)
|
35
|
+
pkg.spec?.should be_true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "repo does not include spec file" do
|
40
|
+
it "returns false" do
|
41
|
+
pkg = described_class.new :name => 'rails'
|
42
|
+
pkg.should_receive(:include?).with(pkg.spec_file).and_return(false)
|
43
|
+
pkg.spec?.should be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#spec" do
|
49
|
+
before do
|
50
|
+
@pkg = described_class.new :name => 'rails'
|
51
|
+
@pkg.should_receive(:in_repo)
|
52
|
+
.at_least(:once)
|
53
|
+
.and_yield
|
54
|
+
File.should_receive(:read)
|
55
|
+
.with(@pkg.spec_file)
|
56
|
+
.at_least(:once)
|
57
|
+
.and_return("spec")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns handle to parsed Polisher::RPM::Spec" do
|
61
|
+
spec = Polisher::RPM::Spec.new
|
62
|
+
Polisher::RPM::Spec.should_receive(:parse)
|
63
|
+
.with('spec')
|
64
|
+
.once
|
65
|
+
.and_return(spec)
|
66
|
+
@pkg.spec.should == spec
|
67
|
+
@pkg.spec.should == spec
|
68
|
+
end
|
69
|
+
|
70
|
+
context "dirty_spec bit is set true" do
|
71
|
+
it "reparses spec" do
|
72
|
+
spec = Polisher::RPM::Spec.new
|
73
|
+
Polisher::RPM::Spec.should_receive(:parse)
|
74
|
+
.with('spec')
|
75
|
+
.twice
|
76
|
+
.and_return(spec)
|
77
|
+
@pkg.spec.should == spec
|
78
|
+
@pkg.dirty_spec = true
|
79
|
+
@pkg.spec.should == spec
|
80
|
+
end
|
81
|
+
|
82
|
+
it "resets dirty_spec bit" do
|
83
|
+
spec = Polisher::RPM::Spec.new
|
84
|
+
Polisher::RPM::Spec.should_receive(:parse).and_return(spec)
|
85
|
+
@pkg.dirty_spec = true
|
86
|
+
@pkg.spec
|
87
|
+
@pkg.dirty_spec.should be_false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#pkg_files" do
|
93
|
+
it "returns spec, .gitignore, sources" do
|
94
|
+
pkg = described_class.new :name => 'thor'
|
95
|
+
pkg.pkg_files.should == [pkg.spec_file, 'sources', '.gitignore']
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "#path" do
|
100
|
+
it "returns Git Cache path for rpm name" do
|
101
|
+
pkg = described_class.new :name => 'thor'
|
102
|
+
GitCache.should_receive(:path_for).with(pkg.rpm_name).and_return "path"
|
103
|
+
pkg.path.should == "path"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#dead?" do
|
108
|
+
before(:each) do
|
109
|
+
@pkg = described_class.new
|
110
|
+
@pkg.should_receive(:in_repo).and_yield
|
111
|
+
end
|
112
|
+
|
113
|
+
context "dead.package exists" do
|
114
|
+
it "returns true" do
|
115
|
+
File.should_receive(:exist?).with('dead.package').and_return(true)
|
116
|
+
@pkg.should be_dead
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "dead.package does not exist" do
|
121
|
+
it "returns false" do
|
122
|
+
File.should_receive(:exist?).with('dead.package').and_return(false)
|
123
|
+
@pkg.should_not be_dead
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end # describe Git::Pkg
|
128
|
+
end # module Polisher
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the MIT license
|
3
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
+
|
5
|
+
require 'polisher/git/pkg'
|
6
|
+
|
7
|
+
module Polisher
|
8
|
+
describe Git::Pkg do
|
9
|
+
describe "#build_srpm" do
|
10
|
+
it "uses package command to build srpm" do
|
11
|
+
gem = Polisher::Gem.new(:path => "")
|
12
|
+
spec = RPM::Spec.new
|
13
|
+
pkg = described_class.new
|
14
|
+
pkg.should_receive(:in_repo).and_yield
|
15
|
+
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
16
|
+
pkg.should_receive(:spec).and_return(spec)
|
17
|
+
spec.should_receive(:upstream_gem).and_return(gem)
|
18
|
+
FileUtils.stub(:ln_s) # stub out ln
|
19
|
+
result = AwesomeSpawn::CommandResult.new "", "", "", 0
|
20
|
+
AwesomeSpawn.should_receive(:run)
|
21
|
+
.with("/usr/bin/fedpkg srpm")
|
22
|
+
.and_return(result)
|
23
|
+
pkg.build_srpm
|
24
|
+
end
|
25
|
+
|
26
|
+
context "package command fails" do
|
27
|
+
it "raises RuntimeError with the command stderr" do
|
28
|
+
gem = Polisher::Gem.new(:path => "")
|
29
|
+
spec = RPM::Spec.new
|
30
|
+
pkg = described_class.new
|
31
|
+
pkg.should_receive(:in_repo).and_yield
|
32
|
+
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
33
|
+
pkg.should_receive(:spec).and_return(spec)
|
34
|
+
spec.should_receive(:upstream_gem).and_return(gem)
|
35
|
+
FileUtils.stub(:ln_s) # stub out ln
|
36
|
+
result = AwesomeSpawn::CommandResult.new "", "", "cmd_error", 1
|
37
|
+
AwesomeSpawn.should_receive(:run)
|
38
|
+
.and_return(result)
|
39
|
+
expect { pkg.build_srpm }.to raise_error(RuntimeError, "cmd_error")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#scratch_build" do
|
45
|
+
it "uses koji to build srpm" do
|
46
|
+
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
47
|
+
pkg.should_receive(:in_repo).and_yield
|
48
|
+
Koji.should_receive(:build).with(:srpm => pkg.srpm, :scratch => true)
|
49
|
+
pkg.scratch_build
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#build" do
|
54
|
+
it "builds srpm and runs scratch build" do
|
55
|
+
pkg = described_class.new
|
56
|
+
pkg.should_receive(:build_srpm)
|
57
|
+
pkg.should_receive(:scratch_build)
|
58
|
+
pkg.build
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end # describe Git::Pkg
|
63
|
+
end # module Polisher
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the MIT license
|
3
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
+
|
5
|
+
require 'polisher/git/pkg'
|
6
|
+
require 'awesome_spawn'
|
7
|
+
|
8
|
+
module Polisher
|
9
|
+
describe Git::Pkg do
|
10
|
+
describe "#git_clone" do
|
11
|
+
it "is an alias for superclass#clone"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#clone" do
|
15
|
+
it "clones package" do
|
16
|
+
# stub out glob / rm_rf
|
17
|
+
Dir.should_receive(:foreach).and_return([])
|
18
|
+
FileUtils.should_receive(:rm_rf).at_least(:once)
|
19
|
+
|
20
|
+
pkg = described_class.new :name => 'rails'
|
21
|
+
pkg.should_receive(:in_repo).and_yield
|
22
|
+
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
23
|
+
|
24
|
+
expected = '/usr/bin/fedpkg clone rubygem-rails'
|
25
|
+
result = AwesomeSpawn::CommandResult.new '', '', '', 0
|
26
|
+
AwesomeSpawn.should_receive(:run).with(expected).and_return(result)
|
27
|
+
pkg.clone
|
28
|
+
end
|
29
|
+
|
30
|
+
it "moves files from pkg subdir to current dir"
|
31
|
+
it "rm's pkg subdir"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
describe "#fetch" do
|
36
|
+
before(:each) do
|
37
|
+
@pkg = described_class.new
|
38
|
+
end
|
39
|
+
|
40
|
+
context "pkg not cloned" do
|
41
|
+
it "clones package" do
|
42
|
+
@pkg.should_receive(:dead?).and_return(false)
|
43
|
+
@pkg.should_receive(:reset!)
|
44
|
+
@pkg.should_receive(:checkout)
|
45
|
+
@pkg.should_receive(:pull)
|
46
|
+
|
47
|
+
@pkg.should_receive(:cloned?).and_return(false)
|
48
|
+
@pkg.should_receive(:clone)
|
49
|
+
@pkg.fetch
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "pkg cloned" do
|
54
|
+
it "does not clone pkg" do
|
55
|
+
@pkg.should_receive(:dead?).and_return(false)
|
56
|
+
@pkg.should_receive(:reset!)
|
57
|
+
@pkg.should_receive(:checkout)
|
58
|
+
@pkg.should_receive(:pull)
|
59
|
+
|
60
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
61
|
+
@pkg.should_not_receive(:clone)
|
62
|
+
@pkg.fetch
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "pkg dead" do
|
67
|
+
it "raises Exception" do
|
68
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
69
|
+
@pkg.should_receive(:dead?).and_return(true)
|
70
|
+
lambda{ @pkg.fetch }.should raise_error(Exception)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "checks out master" do
|
75
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
76
|
+
@pkg.should_receive(:dead?).and_return(false)
|
77
|
+
@pkg.should_receive(:reset!)
|
78
|
+
@pkg.should_receive(:pull)
|
79
|
+
|
80
|
+
@pkg.should_receive(:checkout).with('master')
|
81
|
+
@pkg.fetch
|
82
|
+
end
|
83
|
+
|
84
|
+
it "resets HEAD" do
|
85
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
86
|
+
@pkg.should_receive(:dead?).and_return(false)
|
87
|
+
@pkg.should_receive(:checkout)
|
88
|
+
@pkg.should_receive(:pull)
|
89
|
+
|
90
|
+
@pkg.should_receive(:reset!)
|
91
|
+
@pkg.fetch
|
92
|
+
end
|
93
|
+
|
94
|
+
it "pulls repo" do
|
95
|
+
@pkg.should_receive(:cloned?).and_return(true)
|
96
|
+
@pkg.should_receive(:dead?).and_return(false)
|
97
|
+
@pkg.should_receive(:reset!)
|
98
|
+
@pkg.should_receive(:checkout)
|
99
|
+
|
100
|
+
@pkg.should_receive(:pull)
|
101
|
+
@pkg.fetch
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#valid_targets" do
|
106
|
+
before do
|
107
|
+
@fetch_tgts = described_class.fetch_tgts
|
108
|
+
described_class.fetch_tgt ['t1', 't2']
|
109
|
+
end
|
110
|
+
|
111
|
+
after do
|
112
|
+
described_class.fetch_tgt @fetch_tgts
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns fetchable targets" do
|
116
|
+
pkg = described_class.new
|
117
|
+
pkg.should_receive(:fetch).with('t1')
|
118
|
+
pkg.should_receive(:fetch).with('t2').and_raise(RuntimeError)
|
119
|
+
pkg.valid_targets.should == ['t1']
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#commit" do
|
124
|
+
it "git adds the pkg_files" do
|
125
|
+
pkg = described_class.new(:name => 'rails')
|
126
|
+
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
127
|
+
pkg.should_receive(:pkg_files).and_return(['pkg_files'])
|
128
|
+
expected = "/usr/bin/git add pkg_files"
|
129
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
130
|
+
AwesomeSpawn.should_receive(:run).at_least(:once)
|
131
|
+
.and_return(AwesomeSpawn::CommandResult.new('', '', '', 0))
|
132
|
+
pkg.commit
|
133
|
+
end
|
134
|
+
|
135
|
+
it "commits the package with default msg" do
|
136
|
+
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
137
|
+
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
138
|
+
expected = "/usr/bin/git commit -m 'updated to 1.0.0'"
|
139
|
+
AwesomeSpawn.should_receive(:run!).with(expected)
|
140
|
+
AwesomeSpawn.should_receive(:run).at_least(:once)
|
141
|
+
.and_return(AwesomeSpawn::CommandResult.new('', '', '', 0))
|
142
|
+
pkg.commit
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end # describe Git::Pkg
|
146
|
+
end # module Polisher
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the MIT license
|
3
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
+
|
5
|
+
require 'polisher/git/pkg'
|
6
|
+
require 'awesome_spawn'
|
7
|
+
|
8
|
+
module Polisher
|
9
|
+
describe Git::Pkg do
|
10
|
+
describe "#update_metadata" do
|
11
|
+
it "sets pkg version" do
|
12
|
+
pkg = described_class.new
|
13
|
+
pkg.update_metadata(Polisher::Gem.new(:version => '5.0'))
|
14
|
+
pkg.version.should == '5.0'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#update_spec_to" do
|
19
|
+
before do
|
20
|
+
@pkg = described_class.new
|
21
|
+
@pkg.should_receive(:in_repo).and_yield
|
22
|
+
@pkg.instance_variable_set(:@spec, Polisher::RPM::Spec.new)
|
23
|
+
|
24
|
+
@gem = Polisher::Gem.new
|
25
|
+
end
|
26
|
+
|
27
|
+
it "updates rpm spec" do
|
28
|
+
@pkg.spec.should_receive(:update_to).with(@gem)
|
29
|
+
@pkg.update_spec_to(@gem)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "writes spec to file" do
|
33
|
+
@pkg.spec.should_receive(:update_to)
|
34
|
+
File.should_receive(:write).with(@pkg.spec_file, @pkg.spec.to_string)
|
35
|
+
@pkg.update_spec_to(@gem)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "sets dirty_spec bit" do
|
39
|
+
@pkg.spec.should_receive(:update_to)
|
40
|
+
@pkg.update_spec_to(@gem)
|
41
|
+
@pkg.dirty_spec.should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#gen_sources_for" do
|
46
|
+
it "writes gem md5sum to sources file" do
|
47
|
+
gem = ::Polisher::Gem.new :path => 'path'
|
48
|
+
expected = "#{described_class.md5sum_cmd} #{gem.gem_path} > sources"
|
49
|
+
AwesomeSpawn.should_receive(:run).with(expected)
|
50
|
+
|
51
|
+
File.should_receive(:read).with('sources').and_return('md5sum')
|
52
|
+
File.should_receive(:write)
|
53
|
+
|
54
|
+
pkg = described_class.new
|
55
|
+
pkg.should_receive(:in_repo).and_yield
|
56
|
+
pkg.gen_sources_for(gem)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#ignore" do
|
61
|
+
it "adds gem to .gitignore file" do
|
62
|
+
gem = ::Polisher::Gem.new :name => 'polisher', :version => '4.2.0'
|
63
|
+
f = Object.new
|
64
|
+
File.should_receive('open').with('.gitignore', 'a').and_yield(f)
|
65
|
+
f.should_receive(:write).with("\n#{gem.name}-#{gem.version}.gem")
|
66
|
+
|
67
|
+
pkg = described_class.new
|
68
|
+
pkg.should_receive(:in_repo).and_yield
|
69
|
+
pkg.ignore(gem)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#update_to" do
|
74
|
+
it "updates pkg" do
|
75
|
+
gem = Polisher::Gem.new
|
76
|
+
pkg = described_class.new
|
77
|
+
pkg.should_receive(:update_metadata).with(gem)
|
78
|
+
pkg.should_receive(:update_spec_to).with(gem)
|
79
|
+
pkg.should_receive(:gen_sources_for).with(gem)
|
80
|
+
pkg.should_receive(:ignore).with(gem)
|
81
|
+
pkg.update_to(gem).should == pkg
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end # describe Git::Pkg
|
86
|
+
end # module Polisher
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the MIT license
|
3
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
+
|
5
|
+
require 'polisher/git/pkg'
|
6
|
+
|
7
|
+
module Polisher
|
8
|
+
describe Git::Pkg do
|
9
|
+
describe "#versions_for" do
|
10
|
+
it "git fetches the package" do
|
11
|
+
pkg = described_class.new
|
12
|
+
described_class.should_receive(:new)
|
13
|
+
.with(:name => 'rails')
|
14
|
+
.and_return(pkg)
|
15
|
+
described_class.fetch_tgt.each { |tgt| pkg.should_receive(:fetch).with(tgt) }
|
16
|
+
described_class.versions_for 'rails'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns version of the package" do
|
20
|
+
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
21
|
+
pkg = described_class.new
|
22
|
+
pkg.should_receive(:fetch) # stub out fetch
|
23
|
+
described_class.should_receive(:new).and_return(pkg)
|
24
|
+
pkg.should_receive(:spec).and_return(spec)
|
25
|
+
|
26
|
+
described_class.versions_for('rails').should == ['1.0.0']
|
27
|
+
end
|
28
|
+
|
29
|
+
it "invokes callback with version of package" do
|
30
|
+
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
31
|
+
pkg = described_class.new
|
32
|
+
pkg.should_receive(:fetch) # stub out fetch
|
33
|
+
described_class.should_receive(:new).and_return(pkg)
|
34
|
+
pkg.should_receive(:spec).and_return(spec)
|
35
|
+
|
36
|
+
cb = proc {}
|
37
|
+
cb.should_receive(:call).with(:git, 'rails', ['1.0.0'])
|
38
|
+
described_class.versions_for('rails', &cb)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end # describe Git::Pkg
|
42
|
+
end # module Polisher
|