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
data/lib/polisher/rhn.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Polisher RHN Operations
|
2
|
-
#
|
3
|
-
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
-
require 'polisher/component'
|
6
|
-
|
7
|
-
module Polisher
|
8
|
-
Component.verify("RHN", "pkgwat") do
|
9
|
-
class RHN
|
10
|
-
def self.version_for(name)
|
11
|
-
# TODO
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,177 +0,0 @@
|
|
1
|
-
# Helpers to check versions
|
2
|
-
#
|
3
|
-
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
-
|
6
|
-
require 'polisher/gem'
|
7
|
-
require 'polisher/logger'
|
8
|
-
|
9
|
-
module Polisher
|
10
|
-
class VersionChecker
|
11
|
-
extend Logging
|
12
|
-
|
13
|
-
GEM_TARGET = :gem
|
14
|
-
KOJI_TARGET = :koji
|
15
|
-
FEDORA_TARGET = :fedora
|
16
|
-
GIT_TARGET = :git
|
17
|
-
YUM_TARGET = :yum
|
18
|
-
BODHI_TARGET = :bodhi # fedora dispatches to bodhi so not enabled by default
|
19
|
-
ERRATA_TARGET = :errata # not enabled by default
|
20
|
-
ALL_TARGETS = [GEM_TARGET, KOJI_TARGET, FEDORA_TARGET,
|
21
|
-
GIT_TARGET, YUM_TARGET]
|
22
|
-
|
23
|
-
# Enable the specified target(s) in the list of target to check
|
24
|
-
def self.check(*target)
|
25
|
-
@check_list ||= []
|
26
|
-
target.flatten.each { |t| @check_list << t }
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.should_check?(target)
|
30
|
-
@check_list ||= ALL_TARGETS
|
31
|
-
@check_list.include?(target)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Retrieve all the versions of the specified package using
|
35
|
-
# the configured targets.
|
36
|
-
#
|
37
|
-
# If not specified, all targets are checked
|
38
|
-
# @param [String] name name of package to query
|
39
|
-
# @param [Callable] bl optional block to invoke with versions retrieved
|
40
|
-
# @returns [Hash<target,Array<String>>] returns a hash of target to versions
|
41
|
-
# available for specified package
|
42
|
-
def self.versions_for(name, &bl)
|
43
|
-
versions = {}
|
44
|
-
|
45
|
-
if should_check?(GEM_TARGET)
|
46
|
-
logger.debug "versions_for<gem>(#{name})..."
|
47
|
-
gem_versions = Gem.local_versions_for(name, &bl)
|
48
|
-
logger.debug gem_versions
|
49
|
-
versions.merge! :gem => gem_versions
|
50
|
-
end
|
51
|
-
|
52
|
-
if should_check?(FEDORA_TARGET)
|
53
|
-
begin
|
54
|
-
require 'polisher/fedora'
|
55
|
-
logger.debug "versions_for<fedora>(#{name})..."
|
56
|
-
fedora_versions = Fedora.versions_for(name, &bl)
|
57
|
-
logger.debug fedora_versions
|
58
|
-
versions.merge! :fedora => fedora_versions
|
59
|
-
rescue
|
60
|
-
logger.debug 'unknown'
|
61
|
-
versions.merge! :fedora => unknown_version(:fedora, name, &bl)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
if should_check?(KOJI_TARGET)
|
66
|
-
begin
|
67
|
-
require 'polisher/koji'
|
68
|
-
logger.debug "versions_for<koji>(#{name})..."
|
69
|
-
koji_versions = Koji.versions_for(name, &bl)
|
70
|
-
logger.debug koji_versions
|
71
|
-
versions.merge! :koji => koji_versions
|
72
|
-
rescue
|
73
|
-
logger.debug 'unknown'
|
74
|
-
versions.merge! :koji => unknown_version(:koji, name, &bl)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
if should_check?(GIT_TARGET)
|
79
|
-
begin
|
80
|
-
require 'polisher/git/pkg'
|
81
|
-
logger.debug "versions_for<git>(#{name})..."
|
82
|
-
git_versions = Git::Pkg.versions_for(name, &bl)
|
83
|
-
logger.debug git_versions
|
84
|
-
versions.merge! :git => git_versions
|
85
|
-
rescue
|
86
|
-
logger.debug 'unknown'
|
87
|
-
versions.merge! :git => unknown_version(:git, name, &bl)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
if should_check?(YUM_TARGET)
|
92
|
-
begin
|
93
|
-
require 'polisher/yum'
|
94
|
-
logger.debug "versions_for<yum>(#{name})..."
|
95
|
-
yum_versions = [Yum.version_for(name, &bl)]
|
96
|
-
versions.merge! :yum => yum_versions
|
97
|
-
logger.debug yum_versions
|
98
|
-
rescue
|
99
|
-
logger.debug 'unknown'
|
100
|
-
versions.merge! :yum => unknown_version(:yum, name, &bl)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
if should_check?(BODHI_TARGET)
|
105
|
-
begin
|
106
|
-
require 'polisher/bodhi'
|
107
|
-
logger.debug "versions_for<bodhi>(#{name})..."
|
108
|
-
bodhi_versions = Bodhi.versions_for(name, &bl)
|
109
|
-
versions.merge! :bodhi => bodhi_versions
|
110
|
-
logger.debug bodhi_versions
|
111
|
-
rescue
|
112
|
-
logger.debug 'unknown'
|
113
|
-
versions.merge! :bodhi => unknown_version(:bodhi, name, &bl)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
if should_check?(ERRATA_TARGET)
|
118
|
-
begin
|
119
|
-
require 'polisher/errata'
|
120
|
-
logger.debug "versions_for<errata>(#{name})..."
|
121
|
-
errata_versions = Errata.versions_for(name, &bl)
|
122
|
-
versions.merge! :errata => errata_versions
|
123
|
-
logger.debug errata_versions
|
124
|
-
rescue
|
125
|
-
logger.debug 'unknown'
|
126
|
-
versions.merge! :errata => unknown_version(:errata, name, &bl)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
versions
|
131
|
-
end
|
132
|
-
|
133
|
-
# Return version of package most frequent in all configured targets.
|
134
|
-
# Invokes query as normal then counts versions over all targets and
|
135
|
-
# returns the max.
|
136
|
-
def self.version_for(name)
|
137
|
-
versions = self.versions_for(name).values
|
138
|
-
versions.inject(Hash.new(0)) { |total, i| total[i] += 1; total }.first
|
139
|
-
end
|
140
|
-
|
141
|
-
# Invoke block for specified target w/ an 'unknown' version
|
142
|
-
def self.unknown_version(tgt, name)
|
143
|
-
yield tgt, name, [:unknown]
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# Helper module to be included in components
|
148
|
-
# that contain lists of dependencies which include version information
|
149
|
-
module VersionedDependencies
|
150
|
-
|
151
|
-
# Return list of versions of dependencies of component.
|
152
|
-
#
|
153
|
-
# Requires module define 'deps' method which returns list
|
154
|
-
# of gem names representing component dependencies. List
|
155
|
-
# will be iterated over, versions will be looked up
|
156
|
-
# recursively and returned
|
157
|
-
def dependency_versions(args = {}, &bl)
|
158
|
-
args = {:recursive => true, :dev_deps => true}.merge(args)
|
159
|
-
versions = {}
|
160
|
-
deps.each do |dep|
|
161
|
-
gem = Polisher::Gem.retrieve(dep.name)
|
162
|
-
versions.merge!(gem.versions(args, &bl))
|
163
|
-
end
|
164
|
-
versions
|
165
|
-
end
|
166
|
-
|
167
|
-
# Return list of states which gem dependencies are in
|
168
|
-
def dependency_states
|
169
|
-
states = {}
|
170
|
-
deps.each do |dep|
|
171
|
-
gem = Polisher::Gem.new :name => dep.name
|
172
|
-
states.merge dep.name => gem.state(:check => dep)
|
173
|
-
end
|
174
|
-
states
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
data/lib/polisher/yum.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Polisher Yum Operations
|
2
|
-
#
|
3
|
-
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
-
|
6
|
-
require 'polisher/core'
|
7
|
-
require 'polisher/component'
|
8
|
-
|
9
|
-
module Polisher
|
10
|
-
Component.verify("Yum", 'awesome_spawn') do
|
11
|
-
class Yum
|
12
|
-
include ConfHelpers
|
13
|
-
|
14
|
-
conf_attr :yum_cmd, '/usr/bin/yum'
|
15
|
-
|
16
|
-
# Retrieve version of gem available in yum
|
17
|
-
#
|
18
|
-
# @param [String] name name of gem to loopup
|
19
|
-
# @param [Callable] bl optional callback to invoke with version retrieved
|
20
|
-
# @returns [String] version of gem in yum or nil if not found
|
21
|
-
def self.version_for(name, &bl)
|
22
|
-
require_cmd! yum_cmd
|
23
|
-
|
24
|
-
version = nil
|
25
|
-
result = AwesomeSpawn.run "#{yum_cmd} info rubygem-#{name}"
|
26
|
-
out = result.output
|
27
|
-
|
28
|
-
if out.include?("Version")
|
29
|
-
version = out.lines.to_a.detect { |l| l =~ /^Version.*/ }
|
30
|
-
version = version.split(':').last.strip
|
31
|
-
end
|
32
|
-
bl.call(:yum, name, [version]) unless bl.nil?
|
33
|
-
version
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end # Component.verify("Yum")
|
37
|
-
end # module Polisher
|
data/spec/git_spec.rb
DELETED
@@ -1,445 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed under the MIT license
|
3
|
-
# Copyright (C) 2013-2014 Red Hat, Inc.
|
4
|
-
|
5
|
-
require 'polisher/git'
|
6
|
-
require 'polisher/gem'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
module Polisher
|
10
|
-
describe Git::Repo do
|
11
|
-
describe "#initialize" do
|
12
|
-
it "initializes url" do
|
13
|
-
repo = described_class.new :url => 'repo_url'
|
14
|
-
repo.url.should == 'repo_url'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#path" do
|
19
|
-
it "returns git cache path for url" do
|
20
|
-
repo = described_class.new :url => 'repo_url'
|
21
|
-
Polisher::GitCache.should_receive(:path_for).
|
22
|
-
with('repo_url').
|
23
|
-
and_return('repo_path')
|
24
|
-
repo.path.should == 'repo_path'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#clone" do
|
29
|
-
it "runs git clone" do
|
30
|
-
expected = "/usr/bin/git clone repo_url repo_path"
|
31
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
32
|
-
|
33
|
-
repo = described_class.new :url => 'repo_url'
|
34
|
-
repo.should_receive(:path).and_return('repo_path')
|
35
|
-
repo.clone
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#cloned?" do
|
40
|
-
before(:each) do
|
41
|
-
@repo = described_class.new
|
42
|
-
@repo.should_receive(:path).and_return('repo_path')
|
43
|
-
end
|
44
|
-
|
45
|
-
context "repo path directory exists" do
|
46
|
-
it "returns true" do
|
47
|
-
File.should_receive(:directory?).with('repo_path').and_return(true)
|
48
|
-
@repo.should be_cloned
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "repo path directory does not exist" do
|
53
|
-
it "returns false" do
|
54
|
-
File.should_receive(:directory?).with('repo_path').and_return(false)
|
55
|
-
@repo.should_not be_cloned
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#in_repo" do
|
61
|
-
it "chdir to repo path, invokes block, restores dir" do
|
62
|
-
repo = described_class.new
|
63
|
-
Dir.mktmpdir do |dir|
|
64
|
-
repo.should_receive(:path).and_return(dir)
|
65
|
-
|
66
|
-
expected = Pathname.new(dir).realpath.to_s
|
67
|
-
invoked = false
|
68
|
-
orig = Dir.pwd
|
69
|
-
repo.in_repo do
|
70
|
-
Dir.pwd.should == expected
|
71
|
-
invoked = true
|
72
|
-
end
|
73
|
-
Dir.pwd.should == orig
|
74
|
-
invoked.should be_true
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#file_paths" do
|
80
|
-
it "returns list of all first paths in git repo" do
|
81
|
-
expected = ['file1', 'dir1/file2', 'dir2']
|
82
|
-
repo = described_class.new
|
83
|
-
repo.should_receive(:in_repo).and_yield
|
84
|
-
Dir.should_receive(:[]).with('**/*').and_return(expected)
|
85
|
-
repo.file_paths.should == expected
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "#reset!" do
|
90
|
-
it "resets git repo to head" do
|
91
|
-
expected = "/usr/bin/git reset HEAD~ --hard"
|
92
|
-
repo = described_class.new
|
93
|
-
repo.should_receive(:in_repo).and_yield
|
94
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
95
|
-
repo.reset!
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "#pull" do
|
100
|
-
it "git pulls" do
|
101
|
-
expected = "/usr/bin/git pull"
|
102
|
-
repo = described_class.new
|
103
|
-
repo.should_receive(:in_repo).and_yield
|
104
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
105
|
-
repo.pull
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#checkout" do
|
110
|
-
it "git checks out target" do
|
111
|
-
expected = "/usr/bin/git checkout master"
|
112
|
-
repo = described_class.new
|
113
|
-
repo.should_receive(:in_repo).and_yield
|
114
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
115
|
-
repo.checkout('master')
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#commit" do
|
120
|
-
it "git commits with message" do
|
121
|
-
expected = "/usr/bin/git commit -m 'msg'"
|
122
|
-
repo = described_class.new
|
123
|
-
repo.should_receive(:in_repo).and_yield
|
124
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
125
|
-
repo.commit('msg')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe Git::Pkg do
|
131
|
-
describe "#initialize" do
|
132
|
-
it "initializes name" do
|
133
|
-
pkg = described_class.new :name => 'pkg_name'
|
134
|
-
pkg.name.should == 'pkg_name'
|
135
|
-
end
|
136
|
-
|
137
|
-
it "initializes version" do
|
138
|
-
pkg = described_class.new :version => 'pkg_version'
|
139
|
-
pkg.version.should == 'pkg_version'
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "#rpm_name" do
|
144
|
-
it "returns rubygem-gem_name" do
|
145
|
-
pkg = described_class.new :name => 'rails'
|
146
|
-
pkg.rpm_name.should == 'rubygem-rails'
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "#srpm" do
|
151
|
-
it "returns name of srpm" do
|
152
|
-
pkg = described_class.new :name => 'rails', :version => '1.0.0'
|
153
|
-
pkg.srpm.should == 'rubygem-rails-1.0.0-1.*.src.rpm'
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "#spec_file" do
|
158
|
-
it "returns name of spec file" do
|
159
|
-
pkg = described_class.new :name => 'rails'
|
160
|
-
pkg.spec_file.should == 'rubygem-rails.spec'
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "#spec" do
|
165
|
-
it "returns handle to parsed Polisher::RPM::Spec"
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#pkg_files" do
|
169
|
-
it "returns spec, .gitignore, sources"
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "#path" do
|
173
|
-
it "returns Git Cache path for rpm name"
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#git_clone" do
|
177
|
-
it "is an alias for superclass#clone"
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "#clone" do
|
181
|
-
it "clones package" do
|
182
|
-
# stub out glob / rm_rf
|
183
|
-
Dir.should_receive(:foreach).and_return([])
|
184
|
-
FileUtils.should_receive(:rm_rf).at_least(:once)
|
185
|
-
|
186
|
-
pkg = described_class.new :name => 'rails'
|
187
|
-
pkg.should_receive(:in_repo).and_yield
|
188
|
-
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
189
|
-
|
190
|
-
expected = '/usr/bin/fedpkg clone rubygem-rails'
|
191
|
-
result = AwesomeSpawn::CommandResult.new '', '', '', 0
|
192
|
-
AwesomeSpawn.should_receive(:run).with(expected).and_return(result)
|
193
|
-
pkg.clone
|
194
|
-
end
|
195
|
-
|
196
|
-
it "moves files from pkg subdir to current dir"
|
197
|
-
it "rm's pkg subdir"
|
198
|
-
end
|
199
|
-
|
200
|
-
describe "#dead?" do
|
201
|
-
before(:each) do
|
202
|
-
@pkg = described_class.new
|
203
|
-
@pkg.should_receive(:in_repo).and_yield
|
204
|
-
end
|
205
|
-
|
206
|
-
context "dead.package exists" do
|
207
|
-
it "returns true" do
|
208
|
-
File.should_receive(:exist?).with('dead.package').and_return(true)
|
209
|
-
@pkg.should be_dead
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context "dead.package does not exist" do
|
214
|
-
it "returns false" do
|
215
|
-
File.should_receive(:exist?).with('dead.package').and_return(false)
|
216
|
-
@pkg.should_not be_dead
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe "#fetch" do
|
222
|
-
before(:each) do
|
223
|
-
@pkg = described_class.new
|
224
|
-
end
|
225
|
-
|
226
|
-
context "pkg not cloned" do
|
227
|
-
it "clones package" do
|
228
|
-
@pkg.should_receive(:dead?).and_return(false)
|
229
|
-
@pkg.should_receive(:reset!)
|
230
|
-
@pkg.should_receive(:checkout)
|
231
|
-
@pkg.should_receive(:pull)
|
232
|
-
|
233
|
-
@pkg.should_receive(:cloned?).and_return(false)
|
234
|
-
@pkg.should_receive(:clone)
|
235
|
-
@pkg.fetch
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
context "pkg cloned" do
|
240
|
-
it "does not clone pkg" do
|
241
|
-
@pkg.should_receive(:dead?).and_return(false)
|
242
|
-
@pkg.should_receive(:reset!)
|
243
|
-
@pkg.should_receive(:checkout)
|
244
|
-
@pkg.should_receive(:pull)
|
245
|
-
|
246
|
-
@pkg.should_receive(:cloned?).and_return(true)
|
247
|
-
@pkg.should_not_receive(:clone)
|
248
|
-
@pkg.fetch
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
context "pkg dead" do
|
253
|
-
it "raises Exception" do
|
254
|
-
@pkg.should_receive(:cloned?).and_return(true)
|
255
|
-
@pkg.should_receive(:dead?).and_return(true)
|
256
|
-
lambda{
|
257
|
-
@pkg.fetch
|
258
|
-
}.should raise_error(Exception)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
it "checks out master" do
|
263
|
-
@pkg.should_receive(:cloned?).and_return(true)
|
264
|
-
@pkg.should_receive(:dead?).and_return(false)
|
265
|
-
@pkg.should_receive(:reset!)
|
266
|
-
@pkg.should_receive(:pull)
|
267
|
-
|
268
|
-
@pkg.should_receive(:checkout).with('master')
|
269
|
-
@pkg.fetch
|
270
|
-
end
|
271
|
-
|
272
|
-
it "resets HEAD" do
|
273
|
-
@pkg.should_receive(:cloned?).and_return(true)
|
274
|
-
@pkg.should_receive(:dead?).and_return(false)
|
275
|
-
@pkg.should_receive(:checkout)
|
276
|
-
@pkg.should_receive(:pull)
|
277
|
-
|
278
|
-
@pkg.should_receive(:reset!)
|
279
|
-
@pkg.fetch
|
280
|
-
end
|
281
|
-
|
282
|
-
it "pulls repo" do
|
283
|
-
@pkg.should_receive(:cloned?).and_return(true)
|
284
|
-
@pkg.should_receive(:dead?).and_return(false)
|
285
|
-
@pkg.should_receive(:reset!)
|
286
|
-
@pkg.should_receive(:checkout)
|
287
|
-
|
288
|
-
|
289
|
-
@pkg.should_receive(:pull)
|
290
|
-
@pkg.fetch
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
describe "#update_metadata" do
|
295
|
-
it "sets pkg version" do
|
296
|
-
pkg = described_class.new
|
297
|
-
pkg.update_metadata(Polisher::Gem.new(:version => '5.0'))
|
298
|
-
pkg.version.should == '5.0'
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
describe "#update_spec_to" do
|
303
|
-
it "updates spec metadata"
|
304
|
-
it "updates spec version"
|
305
|
-
it "updates spec release"
|
306
|
-
end
|
307
|
-
|
308
|
-
describe "#gen_sources_for" do
|
309
|
-
it "writes gem md5sum to sources file"
|
310
|
-
end
|
311
|
-
|
312
|
-
describe "#ignore" do
|
313
|
-
it "adds gem to .gitignore file"
|
314
|
-
end
|
315
|
-
|
316
|
-
describe "#update_to" do
|
317
|
-
it "updates rpm spec"
|
318
|
-
it "generates new sources file"
|
319
|
-
it "ignores gem"
|
320
|
-
end
|
321
|
-
|
322
|
-
describe "#commit" do
|
323
|
-
it "git adds the pkg_files" do
|
324
|
-
pkg = described_class.new(:name => 'rails')
|
325
|
-
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
326
|
-
pkg.should_receive(:pkg_files).and_return(['pkg_files'])
|
327
|
-
expected = "/usr/bin/git add pkg_files"
|
328
|
-
AwesomeSpawn.should_receive(:run).with(expected)
|
329
|
-
AwesomeSpawn.should_receive(:run).at_least(:once)
|
330
|
-
.and_return(AwesomeSpawn::CommandResult.new('', '', '', 0))
|
331
|
-
pkg.commit
|
332
|
-
end
|
333
|
-
|
334
|
-
it "commits the package with default msg" do
|
335
|
-
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
336
|
-
pkg.should_receive(:in_repo).at_least(:once).and_yield
|
337
|
-
expected = "/usr/bin/git commit -m 'updated to 1.0.0'"
|
338
|
-
AwesomeSpawn.should_receive(:run!).with(expected)
|
339
|
-
AwesomeSpawn.should_receive(:run).at_least(:once)
|
340
|
-
.and_return(AwesomeSpawn::CommandResult.new('', '', '', 0))
|
341
|
-
pkg.commit
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe "#build_srpm" do
|
346
|
-
it "uses package command to build srpm" do
|
347
|
-
gem = Polisher::Gem.new
|
348
|
-
spec = RPM::Spec.new
|
349
|
-
pkg = described_class.new
|
350
|
-
pkg.should_receive(:in_repo).and_yield
|
351
|
-
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
352
|
-
pkg.should_receive(:spec).and_return(spec)
|
353
|
-
spec.should_receive(:upstream_gem).and_return(gem)
|
354
|
-
FileUtils.stub(:ln_s) # stub out ln
|
355
|
-
result = AwesomeSpawn::CommandResult.new "", "", "", 0
|
356
|
-
AwesomeSpawn.should_receive(:run)
|
357
|
-
.with("/usr/bin/fedpkg srpm")
|
358
|
-
.and_return(result)
|
359
|
-
pkg.build_srpm
|
360
|
-
end
|
361
|
-
|
362
|
-
context "package command fails" do
|
363
|
-
it "raises RuntimeError with the command stderr" do
|
364
|
-
gem = Polisher::Gem.new
|
365
|
-
spec = RPM::Spec.new
|
366
|
-
pkg = described_class.new
|
367
|
-
pkg.should_receive(:in_repo).and_yield
|
368
|
-
pkg.should_receive(:require_cmd!).with('/usr/bin/fedpkg').and_return(true)
|
369
|
-
pkg.should_receive(:spec).and_return(spec)
|
370
|
-
spec.should_receive(:upstream_gem).and_return(gem)
|
371
|
-
FileUtils.stub(:ln_s) # stub out ln
|
372
|
-
result = AwesomeSpawn::CommandResult.new "", "", "cmd_error", 1
|
373
|
-
AwesomeSpawn.should_receive(:run)
|
374
|
-
.and_return(result)
|
375
|
-
expect { pkg.build_srpm }.to raise_error(RuntimeError, "cmd_error")
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
describe "#scratch_build" do
|
381
|
-
it "uses koji to build srpm" do
|
382
|
-
pkg = described_class.new(:name => 'rails', :version => '1.0.0')
|
383
|
-
pkg.should_receive(:in_repo).and_yield
|
384
|
-
Koji.should_receive(:build).with(:srpm => pkg.srpm, :scratch => true)
|
385
|
-
pkg.scratch_build
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
describe "#build" do
|
390
|
-
it "builds srpm and runs scratch build" do
|
391
|
-
pkg = described_class.new
|
392
|
-
pkg.should_receive(:build_srpm)
|
393
|
-
pkg.should_receive(:scratch_build)
|
394
|
-
pkg.build
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
describe "#versions_for" do
|
399
|
-
it "git fetches the package" do
|
400
|
-
pkg = described_class.new
|
401
|
-
described_class.should_receive(:new)
|
402
|
-
.with(:name => 'rails')
|
403
|
-
.and_return(pkg)
|
404
|
-
pkg.should_receive(:fetch).with(described_class.fetch_tgt)
|
405
|
-
described_class.versions_for 'rails'
|
406
|
-
end
|
407
|
-
|
408
|
-
it "returns version of the package" do
|
409
|
-
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
410
|
-
pkg = described_class.new
|
411
|
-
pkg.should_receive(:fetch) # stub out fetch
|
412
|
-
described_class.should_receive(:new).and_return(pkg)
|
413
|
-
pkg.should_receive(:spec).and_return(spec)
|
414
|
-
|
415
|
-
described_class.versions_for('rails').should == ['1.0.0']
|
416
|
-
end
|
417
|
-
|
418
|
-
it "invokes callback with version of package" do
|
419
|
-
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
420
|
-
pkg = described_class.new
|
421
|
-
pkg.should_receive(:fetch) # stub out fetch
|
422
|
-
described_class.should_receive(:new).and_return(pkg)
|
423
|
-
pkg.should_receive(:spec).and_return(spec)
|
424
|
-
|
425
|
-
cb = proc {}
|
426
|
-
cb.should_receive(:call).with(:git, 'rails', ['1.0.0'])
|
427
|
-
described_class.versions_for('rails', &cb)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
end # describe Git::Pkg
|
431
|
-
|
432
|
-
describe Git::Project do
|
433
|
-
describe "#vendored" do
|
434
|
-
context "repo not cloned" do
|
435
|
-
it "clones repo" do
|
436
|
-
git = described_class.new
|
437
|
-
git.should_receive(:cloned?).and_return(false)
|
438
|
-
git.should_receive(:clone)
|
439
|
-
git.should_receive(:vendored_file_paths).and_return([]) # stub out
|
440
|
-
git.vendored
|
441
|
-
end
|
442
|
-
end
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end # module Polisher
|