omnibus 1.3.0 → 2.0.0.rc1

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +30 -0
  4. data/.travis.yml +14 -3
  5. data/CHANGELOG.md +72 -49
  6. data/Gemfile +8 -5
  7. data/NOTICE +2 -2
  8. data/README.md +65 -7
  9. data/Rakefile +12 -3
  10. data/bin/makeself-header.sh +1 -1
  11. data/bin/makeself.sh +2 -2
  12. data/bin/omnibus +2 -2
  13. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  14. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
  15. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
  16. data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
  17. data/functional/packagers/mac_pkg_spec.rb +72 -0
  18. data/lib/omnibus/artifact.rb +11 -13
  19. data/lib/omnibus/build_version.rb +18 -21
  20. data/lib/omnibus/builder.rb +37 -48
  21. data/lib/omnibus/clean_tasks.rb +3 -5
  22. data/lib/omnibus/cli/application.rb +46 -53
  23. data/lib/omnibus/cli/base.rb +16 -19
  24. data/lib/omnibus/cli/build.rb +13 -13
  25. data/lib/omnibus/cli/cache.rb +13 -15
  26. data/lib/omnibus/cli/release.rb +4 -9
  27. data/lib/omnibus/cli.rb +2 -4
  28. data/lib/omnibus/config.rb +43 -23
  29. data/lib/omnibus/exceptions.rb +35 -1
  30. data/lib/omnibus/fetcher.rb +9 -13
  31. data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
  32. data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
  33. data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
  34. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
  35. data/lib/omnibus/fetchers.rb +3 -3
  36. data/lib/omnibus/health_check.rb +126 -127
  37. data/lib/omnibus/library.rb +11 -12
  38. data/lib/omnibus/overrides.rb +6 -8
  39. data/lib/omnibus/package_release.rb +20 -22
  40. data/lib/omnibus/packagers/mac_pkg.rb +285 -0
  41. data/lib/omnibus/project.rb +215 -110
  42. data/lib/omnibus/reports.rb +16 -24
  43. data/lib/omnibus/s3_cacher.rb +15 -21
  44. data/lib/omnibus/software.rb +178 -88
  45. data/lib/omnibus/util.rb +25 -13
  46. data/lib/omnibus/version.rb +2 -2
  47. data/lib/omnibus.rb +11 -13
  48. data/omnibus.gemspec +20 -18
  49. data/spec/artifact_spec.rb +55 -52
  50. data/spec/build_version_spec.rb +121 -129
  51. data/spec/config_spec.rb +40 -0
  52. data/spec/data/projects/chefdk.rb +41 -0
  53. data/spec/data/projects/sample.rb +10 -0
  54. data/spec/data/software/erchef.rb +12 -12
  55. data/spec/data/software/zlib.rb +67 -0
  56. data/spec/fetchers/git_fetcher_spec.rb +55 -48
  57. data/spec/fetchers/net_fetcher_spec.rb +72 -78
  58. data/spec/omnibus_spec.rb +59 -0
  59. data/spec/overrides_spec.rb +64 -64
  60. data/spec/package_release_spec.rb +65 -64
  61. data/spec/packagers/mac_pkg_spec.rb +261 -0
  62. data/spec/project_spec.rb +138 -0
  63. data/spec/s3_cacher_spec.rb +9 -10
  64. data/spec/software_spec.rb +71 -50
  65. data/spec/spec_helper.rb +14 -7
  66. metadata +68 -60
  67. data/.rspec +0 -1
  68. data/.yardopts +0 -6
  69. data/spec/software_dirs_spec.rb +0 -34
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,40 +21,38 @@ require 'omnibus/s3_cacher'
21
21
  module Omnibus
22
22
  module CLI
23
23
  class Cache < Base
24
-
25
24
  class_option :path,
26
- :aliases => [:p],
27
- :type => :string,
28
- :default => Dir.pwd,
29
- :desc => "Path to the Omnibus project root."
25
+ aliases: [:p],
26
+ type: :string,
27
+ default: Dir.pwd,
28
+ desc: 'Path to the Omnibus project root.'
30
29
 
31
30
  namespace :cache
32
31
 
33
- desc "existing", "List source packages which exist in the cache"
32
+ desc 'existing', 'List source packages which exist in the cache'
34
33
  def existing
35
- S3Cache.new.list.each {|s| puts s.name}
34
+ S3Cache.new.list.each { |s| puts s.name }
36
35
  end
37
36
 
38
- desc "list", "List all cached files (by S3 key)"
37
+ desc 'list', 'List all cached files (by S3 key)'
39
38
  def list
40
- S3Cache.new.list_by_key.each {|k| puts k}
39
+ S3Cache.new.list_by_key.each { |k| puts k }
41
40
  end
42
41
 
43
- desc "missing", "Lists source packages that are required but not yet cached"
42
+ desc 'missing', 'Lists source packages that are required but not yet cached'
44
43
  def missing
45
- S3Cache.new.missing.each {|s| puts s.name}
44
+ S3Cache.new.missing.each { |s| puts s.name }
46
45
  end
47
46
 
48
- desc "fetch", "Fetches missing source packages to local tmp dir"
47
+ desc 'fetch', 'Fetches missing source packages to local tmp dir'
49
48
  def fetch
50
49
  S3Cache.new.fetch_missing
51
50
  end
52
51
 
53
- desc "populate", "Populate the S3 Cache"
52
+ desc 'populate', 'Populate the S3 Cache'
54
53
  def populate
55
54
  S3Cache.new.populate
56
55
  end
57
-
58
56
  end
59
57
  end
60
58
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,28 +22,23 @@ require 'json'
22
22
 
23
23
  module Omnibus
24
24
  module CLI
25
-
26
-
27
25
  class Release < Base
28
-
29
26
  namespace :release
30
27
 
31
28
  def initialize(args, options, config)
32
29
  super(args, options, config)
33
30
  end
34
31
 
35
- desc "package PATH", "Upload a single package to S3"
36
- option :public, :type => :boolean, :default => false, :desc => "Make S3 object publicly readable"
32
+ desc 'package PATH', 'Upload a single package to S3'
33
+ option :public, type: :boolean, default: false, desc: 'Make S3 object publicly readable'
37
34
  def package(path)
38
35
  access_policy = options[:public] ? :public_read : :private
39
36
 
40
- uploader = PackageRelease.new(path, :access => access_policy) do |uploaded_item|
37
+ uploader = PackageRelease.new(path, access: access_policy) do |uploaded_item|
41
38
  say("Uploaded #{uploaded_item}", :green)
42
39
  end
43
40
  uploader.release
44
41
  end
45
-
46
42
  end
47
43
  end
48
44
  end
49
-
data/lib/omnibus/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,15 +21,13 @@ require 'omnibus/cli/build'
21
21
 
22
22
  module Omnibus
23
23
  module CLI
24
-
25
24
  class Error < StandardError
26
25
  attr_reader :original
27
26
 
28
- def initialize(msg, original=nil)
27
+ def initialize(msg, original = nil)
29
28
  super(msg)
30
29
  @original = original
31
30
  end
32
31
  end
33
-
34
32
  end
35
33
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,6 @@ require 'omnibus/exceptions'
20
20
  require 'json'
21
21
 
22
22
  module Omnibus
23
-
24
23
  # Global configuration object for Omnibus runs.
25
24
  #
26
25
  # @todo Write a {http://yardoc.org/guides/extending-yard/writing-handlers.html
@@ -39,7 +38,7 @@ module Omnibus
39
38
  # Defaults to `"/var/cache/omnibus/cache"`.
40
39
  #
41
40
  # @return [String]
42
- cache_dir "/var/cache/omnibus/cache"
41
+ default :cache_dir, '/var/cache/omnibus/cache'
43
42
 
44
43
  # @!attribute [rw] source_dir
45
44
  # The absolute path to the directory on the virtual machine where
@@ -48,7 +47,7 @@ module Omnibus
48
47
  # Defaults to `"/var/cache/omnibus/src"`.
49
48
  #
50
49
  # @return [String]
51
- source_dir "/var/cache/omnibus/src"
50
+ default :source_dir, '/var/cache/omnibus/src'
52
51
 
53
52
  # @!attribute [rw] build_dir
54
53
  # The absolute path to the directory on the virtual machine where
@@ -57,7 +56,7 @@ module Omnibus
57
56
  # Defaults to `"/var/cache/omnibus/build"`.
58
57
  #
59
58
  # @return [String]
60
- build_dir "/var/cache/omnibus/build"
59
+ default :build_dir, '/var/cache/omnibus/build'
61
60
 
62
61
  # @!attribute [rw] package_dir
63
62
  # The absolute path to the directory on the virtual machine where
@@ -66,7 +65,18 @@ module Omnibus
66
65
  # Defaults to `"/var/cache/omnibus/pkg"`.
67
66
  #
68
67
  # @return [String]
69
- package_dir "/var/cache/omnibus/pkg"
68
+ default :package_dir, '/var/cache/omnibus/pkg'
69
+
70
+ # @!attribute [rw] package_tmp
71
+ # The absolute path to the directory on the virtual machine where
72
+ # packagers will store intermediate packaging products. Some packaging
73
+ # methods (notably fpm) handle this internally so not all packagers will
74
+ # use this setting.
75
+ #
76
+ # Defaults to `"/var/cache/omnibus/pkg-tmp"`.
77
+ #
78
+ # @return [String]
79
+ default :package_tmp, '/var/cache/omnibus/pkg-tmp'
70
80
 
71
81
  # @!attribute [rw] project_dir
72
82
  # The relative path of the directory containing {Omnibus::Project}
@@ -75,7 +85,7 @@ module Omnibus
75
85
  # Defaults to `"config/projects"`.
76
86
  #
77
87
  # @return [String]
78
- project_dir "config/projects"
88
+ default :project_dir, 'config/projects'
79
89
 
80
90
  # @!attribute [rw] software_dir
81
91
  # The relative path of the directory containing {Omnibus::Software}
@@ -84,7 +94,7 @@ module Omnibus
84
94
  # Defaults to `"config/software"`.
85
95
  #
86
96
  # @return [String]
87
- software_dir "config/software"
97
+ default :software_dir, 'config/software'
88
98
 
89
99
  # @!attribute [rw] project_root
90
100
  # The root directory in which to look for {Omnibus::Project} and
@@ -93,7 +103,7 @@ module Omnibus
93
103
  # Defaults to the current working directory.
94
104
  #
95
105
  # @return [String]
96
- project_root Dir.pwd
106
+ default :project_root, Dir.pwd
97
107
 
98
108
  # @!attribute [rw] install_dir
99
109
  # Installation directory
@@ -104,7 +114,7 @@ module Omnibus
104
114
  # {Omnibus::Project#install_path}
105
115
  #
106
116
  # @return [String]
107
- install_dir "/opt/chef"
117
+ default :install_dir, '/opt/chef'
108
118
 
109
119
  # @!endgroup
110
120
 
@@ -118,7 +128,7 @@ module Omnibus
118
128
  # Defaults to `false`.
119
129
  #
120
130
  # @return [Boolean]
121
- use_s3_caching false
131
+ default :use_s3_caching, false
122
132
 
123
133
  # @!attribute [rw] s3_bucket
124
134
  # The name of the S3 bucket you want to cache software artifacts in.
@@ -126,7 +136,7 @@ module Omnibus
126
136
  # Defaults to `nil`. Must be set if {#use_s3_caching} is `true`.
127
137
  #
128
138
  # @return [String, nil]
129
- s3_bucket nil
139
+ default :s3_bucket, nil
130
140
 
131
141
  # @!attribute [rw] s3_access_key
132
142
  # The S3 access key to use with S3 caching.
@@ -134,7 +144,7 @@ module Omnibus
134
144
  # Defaults to `nil`. Must be set if {#use_s3_caching} is `true`.
135
145
  #
136
146
  # @return [String, nil]
137
- s3_access_key nil
147
+ default :s3_access_key, nil
138
148
 
139
149
  # @!attribute [rw] s3_secret_key
140
150
  # The S3 secret key to use with S3 caching.
@@ -142,7 +152,7 @@ module Omnibus
142
152
  # Defaults to `nil`. Must be set if {#use_s3_caching} is `true.`
143
153
  #
144
154
  # @return [String, nil]
145
- s3_secret_key nil
155
+ default :s3_secret_key, nil
146
156
 
147
157
  # @!endgroup
148
158
 
@@ -154,7 +164,7 @@ module Omnibus
154
164
  # Defaults to `nil`. Must be set to use `release package` command.
155
165
  #
156
166
  # @return [String, nil]
157
- release_s3_bucket nil
167
+ default :release_s3_bucket, nil
158
168
 
159
169
  # @!attribute [rw] release_s3_access_key
160
170
  # The S3 access key to use for S3 artifact release.
@@ -162,7 +172,7 @@ module Omnibus
162
172
  # Defaults to `nil`. Must be set to use `release package` command.
163
173
  #
164
174
  # @return [String, nil]
165
- release_s3_access_key nil
175
+ default :release_s3_access_key, nil
166
176
 
167
177
  # @!attribute [rw] release_s3_secret_key
168
178
  # The S3 secret key to use for S3 artifact release
@@ -170,7 +180,7 @@ module Omnibus
170
180
  # Defaults to `nil`. Must be set to use `release package` command.
171
181
  #
172
182
  # @return [String, nil]
173
- release_s3_secret_key nil
183
+ default :release_s3_secret_key, nil
174
184
 
175
185
  # @!endgroup
176
186
 
@@ -179,12 +189,23 @@ module Omnibus
179
189
  # @!attribute [rw] override_file
180
190
  #
181
191
  # @return [Boolean]
182
- override_file nil
192
+ default :override_file, nil
193
+
194
+ # @!attribute [rw] software_gem
195
+ #
196
+ # The gem to pull software definitions from. This is just the name of the gem, which is used
197
+ # to find the path to your software definitions, and you must also specify this gem in the
198
+ # Gemfile of your project repo in order to include the gem in your bundle.
199
+ #
200
+ # Defaults to "omnibus-software".
201
+ #
202
+ # @return [String, nil]
203
+ default :software_gem, 'omnibus-software'
183
204
 
184
205
  # @!attribute [rw] solaris_compiler
185
206
  #
186
207
  # @return [String, nil]
187
- solaris_compiler nil
208
+ default :solaris_compiler, nil
188
209
 
189
210
  # @!endgroup
190
211
 
@@ -193,7 +214,7 @@ module Omnibus
193
214
  # @!attribute [rw] append_timestamp
194
215
  #
195
216
  # @return [Boolean]
196
- append_timestamp true
217
+ default :append_timestamp, true
197
218
 
198
219
  # # @!endgroup
199
220
 
@@ -202,7 +223,7 @@ module Omnibus
202
223
  # @! attribute [rw] build_retries
203
224
  #
204
225
  # @return [Integer, nil]
205
- build_retries 3
226
+ default :build_retries, 3
206
227
 
207
228
  # @!group Validation Methods
208
229
 
@@ -220,12 +241,11 @@ module Omnibus
220
241
  def self.valid_s3_config?
221
242
  if use_s3_caching
222
243
  unless s3_bucket
223
- raise InvalidS3Configuration.new(s3_bucket, s3_access_key, s3_secret_key)
244
+ fail InvalidS3Configuration.new(s3_bucket, s3_access_key, s3_secret_key)
224
245
  end
225
246
  end
226
247
  end
227
248
 
228
249
  # @!endgroup
229
-
230
250
  end # Config
231
251
  end # Omnibus
@@ -1,5 +1,4 @@
1
1
  module Omnibus
2
-
3
2
  class InvalidS3Configuration < RuntimeError
4
3
  def initialize(s3_bucket, s3_access_key, s3_secret_key)
5
4
  @s3_bucket, @s3_access_key, @s3_secret_key = s3_bucket, s3_access_key, s3_secret_key
@@ -91,6 +90,7 @@ module Omnibus
91
90
  """
92
91
  end
93
92
  end
93
+
94
94
  # Raise this error if a needed Project configuration value has not
95
95
  # been set.
96
96
  class MissingProjectConfiguration < RuntimeError
@@ -111,6 +111,26 @@ module Omnibus
111
111
  end
112
112
  end
113
113
 
114
+ # Raise this error if a needed Software configuration value has not
115
+ # been set.
116
+ class MissingSoftwareConfiguration < RuntimeError
117
+ def initialize(software_name, parameter_name, sample_value)
118
+ @software_name, @parameter_name, @sample_value = software, parameter_name, sample_value
119
+ end
120
+
121
+ def to_s
122
+ """
123
+ You are attempting to build software #{@sofware_name}, but have not specified
124
+ a value for '#{@parameter_name}'!
125
+
126
+ Please add code similar to the following to your software DSL file:
127
+
128
+ #{@parameter_name} '#{@sample_value}'
129
+
130
+ """
131
+ end
132
+ end
133
+
114
134
  class MissingPatch < RuntimeError
115
135
  def initialize(patch_name, search_paths)
116
136
  @patch_name, @search_paths = patch_name, search_paths
@@ -155,4 +175,18 @@ module Omnibus
155
175
  """
156
176
  end
157
177
  end
178
+
179
+ class MissingMacPkgResource < StandardError
180
+ def initialize(missing_file_paths)
181
+ @missing_file_paths = missing_file_paths
182
+ end
183
+
184
+ def to_s
185
+ <<-E
186
+ Your omnibus repo is missing the following files required to build Mac
187
+ packages:
188
+ #{@missing_file_paths.map { |p| "* #{p}" }.join("\n ")}
189
+ E
190
+ end
191
+ end
158
192
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@
18
18
  require 'pp'
19
19
 
20
20
  module Omnibus
21
-
22
21
  # Base class for classes that fetch project sources from the internet.
23
22
  #
24
23
  # @abstract Subclass and override the {#clean}, {#description},
@@ -27,7 +26,6 @@ module Omnibus
27
26
  # @todo Is this class supposed to be abstract or not? Pretty sure
28
27
  # it's supposed to be abstract
29
28
  class Fetcher
30
-
31
29
  # Given an error and a fetcher that generated the error, print a
32
30
  # formatted report of the error and stacktrace, along with fetcher
33
31
  # details to stderr.
@@ -43,7 +41,6 @@ module Omnibus
43
41
  # since we're already outputting the real error and stacktrace
44
42
  # here.
45
43
  class ErrorReporter
46
-
47
44
  def initialize(error, fetcher)
48
45
  @error, @fetcher = error, fetcher
49
46
  end
@@ -61,14 +58,14 @@ module Omnibus
61
58
  # parameters (presumably the kind of fetcher and the software it
62
59
  # is fetching?),
63
60
  def explain(why)
64
- $stderr.puts "* " * 40
61
+ $stderr.puts '* ' * 40
65
62
  $stderr.puts why
66
- $stderr.puts "Fetcher params:"
63
+ $stderr.puts 'Fetcher params:'
67
64
  $stderr.puts indent(@fetcher.description, 2)
68
- $stderr.puts "Exception:"
65
+ $stderr.puts 'Exception:'
69
66
  $stderr.puts indent("#{e.class}: #{e.message.strip}", 2)
70
- Array(e.backtrace).each {|l| $stderr.puts indent(l, 4) }
71
- $stderr.puts "* " * 40
67
+ Array(e.backtrace).each { |l| $stderr.puts indent(l, 4) }
68
+ $stderr.puts '* ' * 40
72
69
  end
73
70
 
74
71
  private
@@ -82,9 +79,8 @@ module Omnibus
82
79
  # @param n [Fixnum] the number of " " characters to indent each line.
83
80
  # @return [String]
84
81
  def indent(string, n)
85
- string.split("\n").map {|l| " ".rjust(n) << l }.join("\n")
82
+ string.split("\n").map { |l| ' '.rjust(n) << l }.join("\n")
86
83
  end
87
-
88
84
  end
89
85
 
90
86
  class UnsupportedSourceLocation < ArgumentError
@@ -129,11 +125,11 @@ module Omnibus
129
125
  elsif software.source[:path]
130
126
  PathFetcher.new(software)
131
127
  else
132
- raise UnsupportedSourceLocation, "Don't know how to fetch software project #{software}"
128
+ fail UnsupportedSourceLocation, "Don't know how to fetch software project #{software}"
133
129
  end
134
130
  end
135
131
 
136
- def self.name(name=NULL_ARG)
132
+ def self.name(name = NULL_ARG)
137
133
  @name = name unless name.equal?(NULL_ARG)
138
134
  @name
139
135
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,10 +16,8 @@
16
16
  #
17
17
 
18
18
  module Omnibus
19
-
20
19
  # Fetcher implementation for projects in git.
21
20
  class GitFetcher < Fetcher
22
-
23
21
  name :git
24
22
 
25
23
  attr_reader :source
@@ -34,7 +32,7 @@ module Omnibus
34
32
  end
35
33
 
36
34
  def description
37
- s=<<-E
35
+ <<-E
38
36
  repo URI: #{@source[:git]}
39
37
  local location: #{@project_dir}
40
38
  E
@@ -47,9 +45,9 @@ E
47
45
 
48
46
  def clean
49
47
  if existing_git_clone?
50
- log "cleaning existing build"
51
- clean_cmd = "git clean -fdx"
52
- shell = Mixlib::ShellOut.new(clean_cmd, :live_stream => STDOUT, :cwd => project_dir)
48
+ log 'cleaning existing build'
49
+ clean_cmd = 'git clean -fdx'
50
+ shell = Mixlib::ShellOut.new(clean_cmd, live_stream: STDOUT, cwd: project_dir)
53
51
  shell.run_command
54
52
  shell.error!
55
53
  end
@@ -76,7 +74,7 @@ E
76
74
  raise
77
75
  else
78
76
  # Deal with github failing all the time :(
79
- time_to_sleep = 5 * (2 ** retries)
77
+ time_to_sleep = 5 * (2**retries)
80
78
  retries += 1
81
79
  log "git clone/fetch failed for #{@source} #{retries} time(s), retrying in #{time_to_sleep}s"
82
80
  sleep(time_to_sleep)
@@ -87,9 +85,9 @@ E
87
85
  private
88
86
 
89
87
  def clone
90
- puts "cloning the source from git"
88
+ puts 'cloning the source from git'
91
89
  clone_cmd = "git clone #{@source[:git]} #{project_dir}"
92
- shell = Mixlib::ShellOut.new(clone_cmd, :live_stream => STDOUT)
90
+ shell = Mixlib::ShellOut.new(clone_cmd, live_stream: STDOUT)
93
91
  shell.run_command
94
92
  shell.error!
95
93
  end
@@ -98,7 +96,7 @@ E
98
96
  sha_ref = target_revision
99
97
 
100
98
  checkout_cmd = "git checkout #{sha_ref}"
101
- shell = Mixlib::ShellOut.new(checkout_cmd, :live_stream => STDOUT, :cwd => project_dir)
99
+ shell = Mixlib::ShellOut.new(checkout_cmd, live_stream: STDOUT, cwd: project_dir)
102
100
  shell.run_command
103
101
  shell.error!
104
102
  end
@@ -106,7 +104,7 @@ E
106
104
  def fetch_updates
107
105
  puts "fetching updates and resetting to revision #{target_revision}"
108
106
  fetch_cmd = "git fetch origin && git fetch origin --tags && git reset --hard #{target_revision}"
109
- shell = Mixlib::ShellOut.new(fetch_cmd, :live_stream => STDOUT, :cwd => project_dir)
107
+ shell = Mixlib::ShellOut.new(fetch_cmd, live_stream: STDOUT, cwd: project_dir)
110
108
  shell.run_command
111
109
  shell.error!
112
110
  end
@@ -121,8 +119,8 @@ E
121
119
 
122
120
  def current_revision
123
121
  @current_rev ||= begin
124
- rev_cmd = "git rev-parse HEAD"
125
- shell = Mixlib::ShellOut.new(rev_cmd, :live_stream => STDOUT, :cwd => project_dir)
122
+ rev_cmd = 'git rev-parse HEAD'
123
+ shell = Mixlib::ShellOut.new(rev_cmd, live_stream: STDOUT, cwd: project_dir)
126
124
  shell.run_command
127
125
  shell.error!
128
126
  output = shell.stdout
@@ -154,13 +152,11 @@ E
154
152
  # tags. We take care to only return exact matches in
155
153
  # process_remote_list.
156
154
  cmd = "git ls-remote origin #{ref}*"
157
- shell = Mixlib::ShellOut.new(cmd, :live_stream => STDOUT, :cwd => project_dir)
155
+ shell = Mixlib::ShellOut.new(cmd, live_stream: STDOUT, cwd: project_dir)
158
156
  shell.run_command
159
157
  shell.error!
160
158
  commit_ref = process_remote_list(shell.stdout, ref)
161
- if !commit_ref
162
- raise "Could not parse SHA reference"
163
- end
159
+ fail 'Could not parse SHA reference' unless commit_ref
164
160
  commit_ref
165
161
  rescue Exception => e
166
162
  if retries >= 3
@@ -168,7 +164,7 @@ E
168
164
  raise
169
165
  else
170
166
  # Deal with github failing all the time :(
171
- time_to_sleep = 5 * (2 ** retries)
167
+ time_to_sleep = 5 * (2**retries)
172
168
  retries += 1
173
169
  log "git ls-remote failed for #{@source} #{retries} time(s), retrying in #{time_to_sleep}s"
174
170
  sleep(time_to_sleep)