berkshelf 7.0.9 → 8.0.9

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -13
  3. data/Rakefile +2 -2
  4. data/berkshelf.gemspec +13 -5
  5. data/bin/berks +1 -1
  6. data/lib/berkshelf/api_client/chef_server_connection.rb +4 -6
  7. data/lib/berkshelf/api_client/remote_cookbook.rb +1 -1
  8. data/lib/berkshelf/api_client.rb +2 -2
  9. data/lib/berkshelf/berksfile.rb +34 -34
  10. data/lib/berkshelf/chef_config_compat.rb +1 -1
  11. data/lib/berkshelf/cli.rb +5 -5
  12. data/lib/berkshelf/community_rest.rb +3 -3
  13. data/lib/berkshelf/config.rb +2 -2
  14. data/lib/berkshelf/cookbook_store.rb +2 -4
  15. data/lib/berkshelf/core_ext/file_utils.rb +3 -3
  16. data/lib/berkshelf/downloader.rb +6 -6
  17. data/lib/berkshelf/errors.rb +3 -0
  18. data/lib/berkshelf/file_syncer.rb +10 -12
  19. data/lib/berkshelf/installer.rb +7 -7
  20. data/lib/berkshelf/location.rb +4 -4
  21. data/lib/berkshelf/locations/git.rb +6 -12
  22. data/lib/berkshelf/locations/github.rb +1 -1
  23. data/lib/berkshelf/lockfile.rb +9 -9
  24. data/lib/berkshelf/mixin/git.rb +2 -2
  25. data/lib/berkshelf/packager.rb +40 -6
  26. data/lib/berkshelf/shell.rb +1 -1
  27. data/lib/berkshelf/shell_out.rb +4 -3
  28. data/lib/berkshelf/source.rb +2 -2
  29. data/lib/berkshelf/source_uri.rb +1 -1
  30. data/lib/berkshelf/ssl_policies.rb +6 -8
  31. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  32. data/lib/berkshelf/uploader.rb +36 -36
  33. data/lib/berkshelf/validator.rb +13 -8
  34. data/lib/berkshelf/version.rb +1 -1
  35. data/lib/berkshelf/visualizer.rb +2 -2
  36. data/lib/berkshelf.rb +7 -8
  37. data/spec/config/knife.rb +1 -1
  38. data/spec/spec_helper.rb +1 -1
  39. data/spec/support/git.rb +19 -19
  40. data/spec/support/path_helpers.rb +4 -4
  41. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  42. data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +3 -3
  43. data/spec/unit/berkshelf/community_rest_spec.rb +3 -3
  44. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
  45. data/spec/unit/berkshelf/dependency_spec.rb +1 -1
  46. data/spec/unit/berkshelf/location_spec.rb +1 -1
  47. data/spec/unit/berkshelf/locations/git_spec.rb +2 -5
  48. data/spec/unit/berkshelf/lockfile_spec.rb +2 -2
  49. data/spec/unit/berkshelf/ridley_compat_spec.rb +1 -1
  50. data/spec/unit/berkshelf/source_spec.rb +22 -12
  51. data/spec/unit/berkshelf/ssl_policies_spec.rb +0 -1
  52. data/spec/unit/berkshelf/validator_spec.rb +10 -7
  53. metadata +13 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f8c64894fa5e6b2ec2e82b6cc2f4835d67faf33204e5bf1412e4a5eea9fb0b0
4
- data.tar.gz: 3dd04763b8ac3735045e7296e498d112dcba3d34fef9c32263f7f8b557faa149
3
+ metadata.gz: 80b38fc167aeaac8e33a0219cc4ada1bf3e1614a5553294cabfdc7460c5f56b6
4
+ data.tar.gz: 4f642360c7e11c3946c8463cd422dd2279a27f3bcf6512481183dd55e98613d8
5
5
  SHA512:
6
- metadata.gz: 16a792fea670f247f48880b806f47fa2c50c55aa5cc1c255f2a7f47232adea30eb6360c7f2c957b51c380555dc9aaa6ec242f657ec88101dc5804a4147220954
7
- data.tar.gz: 15e850ce857ec01c3b42f319fc159169d7211bf5eb2ed828dec7b4010607860ba47abab36269f1a8fd83817e3310a5b299ed2a32f6de8e7ca4ff412e8534fb51
6
+ metadata.gz: 452b88f63d021f69c75c196f3bd39e1e4f4595e208d75b1f88bc190964c79d05ce8fabc03726884d22396072c00c63fd8423194b495054e96c46cc9439d11bc7
7
+ data.tar.gz: d05010ba4e991b5300b1bda01f1efc73f797e1f85af0666095ff633524f1e3ec54ab650a0ecb81bd59402fd100f6249af7e7fa31f36d526192d88212b32ac5fa
data/Gemfile CHANGED
@@ -2,19 +2,13 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :changelog do
6
- gem "github_changelog_generator"
7
- end
8
-
9
5
  group :build do
10
6
  gem "rake", ">= 10.1"
11
7
  end
12
8
 
13
9
  group :development do
14
- # these all deliberately float because berkshelf has a Gemfile.lock that
15
- # equality pins them. temporarily pin as necessary for API breaks.
16
- gem "chef-bin" # for the proxy tests
17
- gem "aruba", ">= 0.10.0"
10
+ gem "aruba", "~> 0.10" # Stay below 1 until aruba/in_process monkeypatching stops
11
+ gem "cucumber", "< 4.0" # until we identify what is generating the ~@no_run tag in CI
18
12
  gem "cucumber-expressions", "= 5.0.13"
19
13
  gem "chef-zero", ">= 4.0"
20
14
  gem "dep_selector", ">= 1.0"
@@ -23,11 +17,7 @@ group :development do
23
17
  gem "rspec-its", ">= 1.2"
24
18
  gem "webmock", ">= 1.11"
25
19
  gem "http", ">= 0.9.8"
26
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
27
- end
28
-
29
- group :docs do
30
- gem "yard", ">= 0.8"
20
+ gem "chefstyle"
31
21
  end
32
22
 
33
23
  instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
data/Rakefile CHANGED
@@ -14,8 +14,8 @@ begin
14
14
  require "cucumber"
15
15
  require "cucumber/rake/task"
16
16
  Cucumber::Rake::Task.new(:features) do |t|
17
- if RUBY_PLATFORM =~ WINDOWS_PLATFORM
18
- t.cucumber_opts = "--tags ~@not-windows"
17
+ if RUBY_PLATFORM =~ WINDOWS_PLATFORM || RUBY_PLATFORM =~ /darwin/
18
+ t.cucumber_opts = "--tags 'not @not-windows'"
19
19
  end
20
20
  end
21
21
  rescue LoadError
data/berkshelf.gemspec CHANGED
@@ -1,5 +1,4 @@
1
- # -*- encoding: utf-8; mode: ruby -*-
2
- require File.expand_path("../lib/berkshelf/version", __FILE__)
1
+ require File.expand_path("lib/berkshelf/version", __dir__)
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.authors = [
@@ -26,8 +25,13 @@ Gem::Specification.new do |s|
26
25
  s.name = "berkshelf"
27
26
  s.require_paths = ["lib"]
28
27
  s.version = Berkshelf::VERSION
29
- s.required_ruby_version = ">= 2.4.0"
28
+ s.required_ruby_version = ">= 2.7.0"
30
29
  s.required_rubygems_version = ">= 2.0.0"
30
+ s.metadata = {
31
+ "bug_tracker_uri" => "https://github.com/chef/berkshelf/issues",
32
+ "source_code_uri" => "https://github.com/chef/berkshelf",
33
+ "changelog_uri" => "https://github.com/chef/berkshelf/blob/main/CHANGELOG.md",
34
+ }
31
35
 
32
36
  s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
33
37
  s.add_dependency "cleanroom", "~> 1.0"
@@ -36,9 +40,13 @@ Gem::Specification.new do |s|
36
40
  s.add_dependency "solve", "~> 4.0"
37
41
  s.add_dependency "thor", ">= 0.20"
38
42
  s.add_dependency "octokit", "~> 4.0"
39
- s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
43
+ s.add_dependency "mixlib-archive", ">= 1.1.4", "< 2.0" # needed for ruby 3.0 / Dir.chdir removal
40
44
  s.add_dependency "concurrent-ruby", "~> 1.0"
41
- s.add_dependency "chef", ">= 13.6.52"
45
+ if RUBY_VERSION.match?(/3.0/)
46
+ s.add_dependency "chef", "~> 17.0" # needed for --skip-syntax-check
47
+ elsif
48
+ s.add_dependency "chef", ">= 15.7.32"
49
+ end
42
50
  s.add_dependency "chef-config"
43
51
  # this is required for Mixlib::Config#from_json
44
52
  s.add_dependency "mixlib-config", ">= 2.2.5"
data/bin/berks CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $:.push File.expand_path("../../lib", __FILE__)
2
+ $:.push File.expand_path("../lib", __dir__)
3
3
  require "berkshelf/cli"
4
4
 
5
5
  Berkshelf::Cli::Runner.new(ARGV.dup).execute!
@@ -5,15 +5,13 @@ module Berkshelf
5
5
  require_relative "errors"
6
6
 
7
7
  class ChefServerConnection
8
- attr_reader :client
9
-
10
- def initialize(*args)
11
- @client = Berkshelf::RidleyCompat.new(*args)
12
- @url = args[0][:server_url]
8
+ def initialize(**args)
9
+ @client = Berkshelf::RidleyCompat.new(**args)
10
+ @url = args[:server_url]
13
11
  end
14
12
 
15
13
  def universe
16
- response = client.get("universe")
14
+ response = @client.get("universe")
17
15
 
18
16
  [].tap do |cookbooks|
19
17
  response.each do |name, versions|
@@ -1,4 +1,4 @@
1
- require "json"
1
+ require "json" unless defined?(JSON)
2
2
  require "chef/mash"
3
3
 
4
4
  module Berkshelf
@@ -16,8 +16,8 @@ module Berkshelf
16
16
  Connection.new(*args)
17
17
  end
18
18
 
19
- def chef_server(*args)
20
- ChefServerConnection.new(*args)
19
+ def chef_server(**args)
20
+ ChefServerConnection.new(**args)
21
21
  end
22
22
  end
23
23
  end
@@ -118,7 +118,7 @@ module Berkshelf
118
118
  # cookbook 'artifact', path: '/Users/reset/code/artifact'
119
119
  #
120
120
  # @example a cookbook dependency that will be retrieved from a Git server
121
- # cookbook 'artifact', git: 'git://github.com/RiotGames/artifact-cookbook.git'
121
+ # cookbook 'artifact', git: 'https://github.com/chef/artifact-cookbook.git'
122
122
  #
123
123
  # @overload cookbook(name, version_constraint, options = {})
124
124
  # @param [#to_s] name
@@ -156,7 +156,7 @@ module Berkshelf
156
156
  options[:group] += @active_group
157
157
  end
158
158
 
159
- add_dependency(name, constraint, options)
159
+ add_dependency(name, constraint, **options)
160
160
  end
161
161
  expose :cookbook
162
162
 
@@ -500,7 +500,7 @@ module Berkshelf
500
500
  latest = cookbooks.select do |cookbook|
501
501
  (include_non_satisfying || dependency.version_constraint.satisfies?(cookbook.version)) &&
502
502
  Semverse::Version.coerce(cookbook.version) > dependency.locked_version
503
- end.sort_by(&:version).last
503
+ end.max_by(&:version)
504
504
 
505
505
  unless latest.nil?
506
506
  hash[name] ||= {
@@ -644,7 +644,7 @@ module Berkshelf
644
644
  FileUtils.mkdir_p(cookbook_destination)
645
645
 
646
646
  # Dir.glob does not support backslash as a File separator
647
- src = cookbook.path.to_s.tr('\\', "/")
647
+ src = cookbook.path.to_s.tr("\\", "/")
648
648
  files = FileSyncer.glob(File.join(src, "**/*"))
649
649
 
650
650
  # strip directories
@@ -740,41 +740,41 @@ module Berkshelf
740
740
 
741
741
  private
742
742
 
743
- # Ensure the lockfile is present on disk.
744
- #
745
- # @raise [LockfileNotFound]
746
- # if the lockfile does not exist on disk
747
- #
748
- # @return [true]
743
+ # Ensure the lockfile is present on disk.
744
+ #
745
+ # @raise [LockfileNotFound]
746
+ # if the lockfile does not exist on disk
747
+ #
748
+ # @return [true]
749
749
  def validate_lockfile_present!
750
750
  raise LockfileNotFound unless lockfile.present?
751
751
 
752
752
  true
753
753
  end
754
754
 
755
- # Ensure that all dependencies defined in the Berksfile exist in this
756
- # lockfile.
757
- #
758
- # @raise [LockfileOutOfSync]
759
- # if there are dependencies specified in the Berksfile which do not
760
- # exist (or are not satisifed by) the lockfile
761
- #
762
- # @return [true]
755
+ # Ensure that all dependencies defined in the Berksfile exist in this
756
+ # lockfile.
757
+ #
758
+ # @raise [LockfileOutOfSync]
759
+ # if there are dependencies specified in the Berksfile which do not
760
+ # exist (or are not satisifed by) the lockfile
761
+ #
762
+ # @return [true]
763
763
  def validate_lockfile_trusted!
764
764
  raise LockfileOutOfSync unless lockfile.trusted?
765
765
 
766
766
  true
767
767
  end
768
768
 
769
- # Ensure that all dependencies in the lockfile are installed on this
770
- # system. You should validate that the lockfile can be trusted before
771
- # using this method.
772
- #
773
- # @raise [DependencyNotInstalled]
774
- # if the dependency in the lockfile is not in the Berkshelf shelf on
775
- # this system
776
- #
777
- # @return [true]
769
+ # Ensure that all dependencies in the lockfile are installed on this
770
+ # system. You should validate that the lockfile can be trusted before
771
+ # using this method.
772
+ #
773
+ # @raise [DependencyNotInstalled]
774
+ # if the dependency in the lockfile is not in the Berkshelf shelf on
775
+ # this system
776
+ #
777
+ # @return [true]
778
778
  def validate_dependencies_installed!
779
779
  lockfile.graph.locks.each do |_, dependency|
780
780
  unless dependency.installed?
@@ -785,13 +785,13 @@ module Berkshelf
785
785
  true
786
786
  end
787
787
 
788
- # Determine if any cookbooks were specified that aren't in our shelf.
789
- #
790
- # @param [Array<String>] names
791
- # a list of cookbook names
792
- #
793
- # @raise [DependencyNotFound]
794
- # if a cookbook name is given that does not exist
788
+ # Determine if any cookbooks were specified that aren't in our shelf.
789
+ #
790
+ # @param [Array<String>] names
791
+ # a list of cookbook names
792
+ #
793
+ # @raise [DependencyNotFound]
794
+ # if a cookbook name is given that does not exist
795
795
  def validate_cookbook_names!(names)
796
796
  missing = names - lockfile.graph.locks.keys
797
797
 
@@ -1,6 +1,6 @@
1
1
  require "chef-config/config"
2
2
  require "chef-config/workstation_config_loader"
3
- require "socket" # FIXME: why?
3
+ require "socket" unless defined?(Socket) # FIXME: why?
4
4
 
5
5
  module Berkshelf
6
6
  class ChefConfigCompat
data/lib/berkshelf/cli.rb CHANGED
@@ -419,11 +419,11 @@ module Berkshelf
419
419
 
420
420
  private
421
421
 
422
- # Print a list of the given cookbooks. This is used by various
423
- # methods like {list} and {contingent}.
424
- #
425
- # @param [Array<CachedCookbook>] cookbooks
426
- #
422
+ # Print a list of the given cookbooks. This is used by various
423
+ # methods like {list} and {contingent}.
424
+ #
425
+ # @param [Array<CachedCookbook>] cookbooks
426
+ #
427
427
  def print_list(cookbooks)
428
428
  Array(cookbooks).sort.each do |cookbook|
429
429
  Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
@@ -1,5 +1,5 @@
1
- require "retryable"
2
- require "mixlib/archive"
1
+ require "retryable" unless defined?(Retryable)
2
+ require "mixlib/archive" unless defined?(Mixlib::Archive)
3
3
 
4
4
  module Berkshelf
5
5
  class CommunityREST
@@ -75,7 +75,7 @@ module Berkshelf
75
75
  @retries = options.delete(:retries)
76
76
  @retry_interval = options.delete(:retry_interval)
77
77
 
78
- @connection = Berkshelf::RidleyCompatJSON.new(options)
78
+ @connection = Berkshelf::RidleyCompatJSON.new(**options)
79
79
  end
80
80
 
81
81
  # Download and extract target cookbook archive to the local file system,
@@ -1,5 +1,5 @@
1
- require "mixlib/config"
2
- require "openssl"
1
+ require "mixlib/config" unless defined?(Mixlib::Config)
2
+ require "openssl" unless defined?(OpenSSL)
3
3
 
4
4
  # we need this method, but have to inject it into mixlib-config directly
5
5
  # to have it available from config contexts
@@ -1,4 +1,4 @@
1
- require "fileutils"
1
+ require "fileutils" unless defined?(FileUtils)
2
2
  require "chef/exceptions"
3
3
 
4
4
  module Berkshelf
@@ -49,9 +49,7 @@ module Berkshelf
49
49
 
50
50
  # Destroy the contents of the initialized storage path.
51
51
  def clean!
52
- Dir.chdir(storage_path) do
53
- FileUtils.rm_rf(Dir.glob("*"))
54
- end
52
+ FileUtils.rm_rf(Dir.glob("#{storage_path}/*"))
55
53
  end
56
54
 
57
55
  # Import a cookbook found on the local filesystem into this instance of the cookbook store.
@@ -1,4 +1,4 @@
1
- require "fileutils"
1
+ require "fileutils" unless defined?(FileUtils)
2
2
 
3
3
  module FileUtils
4
4
  class << self
@@ -14,10 +14,10 @@ module FileUtils
14
14
  # symlink on Linux
15
15
  # @see {FileUtils::mv}
16
16
  def mv(src, dest, options = {})
17
- old_mv(src, dest, options)
17
+ old_mv(src, dest, **options)
18
18
  rescue Errno::EACCES, Errno::ENOENT
19
19
  options.delete(:force) if options.key?(:force)
20
- FileUtils.cp_r(src, dest, options)
20
+ FileUtils.cp_r(src, dest, **options)
21
21
  FileUtils.rm_rf(src)
22
22
  end
23
23
  end
@@ -1,7 +1,7 @@
1
- require "net/http"
2
- require "mixlib/archive"
1
+ require "net/http" unless defined?(Net::HTTP)
2
+ require "mixlib/archive" unless defined?(Mixlib::Archive)
3
3
  require_relative "ssl_policies"
4
- require "faraday"
4
+ require "faraday" unless defined?(Faraday)
5
5
 
6
6
  module Berkshelf
7
7
  class Downloader
@@ -84,7 +84,7 @@ module Berkshelf
84
84
  client_key: source.options[:client_key] || Berkshelf::Config.instance.chef.client_key,
85
85
  ssl: source.options[:ssl],
86
86
  }
87
- RidleyCompat.new_client(credentials) do |conn|
87
+ RidleyCompat.new_client(**credentials) do |conn|
88
88
  cookbook = Chef::CookbookVersion.load(name, version)
89
89
  manifest = cookbook.cookbook_manifest
90
90
  manifest.by_parent_directory.each do |segment, files|
@@ -145,14 +145,14 @@ module Berkshelf
145
145
 
146
146
  File.join(unpack_dir, cookbook_directory)
147
147
  when :uri
148
- require "open-uri"
148
+ require "open-uri" unless defined?(OpenURI)
149
149
 
150
150
  tmp_dir = Dir.mktmpdir
151
151
  archive_path = Pathname.new(tmp_dir) + "#{name}-#{version}.tar.gz"
152
152
  unpack_dir = Pathname.new(tmp_dir) + "#{name}-#{version}"
153
153
 
154
154
  url = remote_cookbook.location_path
155
- open(url, "rb") do |remote_file|
155
+ URI.open(url, "rb") do |remote_file|
156
156
  archive_path.open("wb") { |local_file| local_file.write remote_file.read }
157
157
  end
158
158
 
@@ -91,6 +91,7 @@ module Berkshelf
91
91
 
92
92
  class CookbookSyntaxError < BerkshelfError; set_status_code(107); end
93
93
  class ConstraintNotSatisfied < BerkshelfError; set_status_code(111); end
94
+
94
95
  class BerksfileReadError < BerkshelfError
95
96
  set_status_code(113)
96
97
 
@@ -254,6 +255,7 @@ module Berkshelf
254
255
  end
255
256
 
256
257
  class UploadFailure < BerkshelfError; end
258
+
257
259
  class FrozenCookbook < UploadFailure
258
260
  set_status_code(126)
259
261
 
@@ -436,6 +438,7 @@ module Berkshelf
436
438
  end
437
439
 
438
440
  class DuplicateDemand < BerkshelfError; set_status_code(138); end
441
+
439
442
  class LockfileNotFound < BerkshelfError
440
443
  set_status_code(140)
441
444
 
@@ -1,4 +1,4 @@
1
- require "fileutils"
1
+ require "fileutils" unless defined?(FileUtils)
2
2
 
3
3
  module Berkshelf
4
4
  module FileSyncer
@@ -24,8 +24,8 @@ module Berkshelf
24
24
  # versions of windows points at 'C:\users'. Some users have their
25
25
  # temp directory still referring to 'C:\Documents and Settings'.
26
26
  #
27
- def glob(pattern)
28
- Dir.glob(pattern, File::FNM_DOTMATCH).sort.reject do |file|
27
+ def glob(pattern, **kwargs)
28
+ Dir.glob(pattern, File::FNM_DOTMATCH, **kwargs).sort.reject do |file|
29
29
  basename = File.basename(file)
30
30
  IGNORED_FILES.include?(basename)
31
31
  end
@@ -65,11 +65,10 @@ module Berkshelf
65
65
  [exclude, "#{exclude}/*"]
66
66
  end.flatten
67
67
 
68
- source_files = Dir.chdir(source) do
69
- glob("**/*").reject do |source_file|
68
+ source_files =
69
+ glob("**/*", base: source).reject do |source_file|
70
70
  excludes.any? { |exclude| File.fnmatch?(exclude, source_file, File::FNM_DOTMATCH) }
71
71
  end
72
- end
73
72
 
74
73
  # Ensure the destination directory exists
75
74
  FileUtils.mkdir_p(destination) unless File.directory?(destination)
@@ -88,10 +87,11 @@ module Berkshelf
88
87
  target = File.readlink(source_file)
89
88
 
90
89
  destination = File.expand_path(destination)
91
- Dir.chdir(destination) do
92
- FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
93
- end
90
+ FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
94
91
  when :file
92
+ # TODO: Workaround issue related to [1] which impacts running ChefSpec on Github Actions
93
+ # [1] https://github.com/docker/for-linux/issues/1015
94
+ FileUtils.touch(source_file)
95
95
  FileUtils.cp(source_file, "#{destination}/#{relative_path}")
96
96
  else
97
97
  type = File.ftype(source_file)
@@ -103,9 +103,7 @@ module Berkshelf
103
103
 
104
104
  if options[:delete]
105
105
  # Remove any files in the destination that are not in the source files
106
- destination_files = Dir.chdir(destination) do
107
- glob("**/*")
108
- end
106
+ destination_files = glob("**/*", base: destination)
109
107
 
110
108
  # Remove any extra files that are present in the destination, but are
111
109
  # not in the source list
@@ -19,13 +19,13 @@ module Berkshelf
19
19
  def build_universe
20
20
  berksfile.sources.collect do |source|
21
21
  Thread.new do
22
- begin
23
- Berkshelf.formatter.msg("Fetching cookbook index from #{source}...")
24
- source.build_universe
25
- rescue Berkshelf::APIClientError => ex
26
- Berkshelf.formatter.warn "Error retrieving universe from source: #{source}"
27
- Berkshelf.formatter.warn " * [#{ex.class}] #{ex}"
28
- end
22
+
23
+ Berkshelf.formatter.msg("Fetching cookbook index from #{source}...")
24
+ source.build_universe
25
+ rescue Berkshelf::APIClientError => ex
26
+ Berkshelf.formatter.warn "Error retrieving universe from source: #{source}"
27
+ Berkshelf.formatter.warn " * [#{ex.class}] #{ex}"
28
+
29
29
  end
30
30
  end.map(&:join)
31
31
  end
@@ -9,7 +9,7 @@ module Berkshelf
9
9
  # is returned.
10
10
  #
11
11
  # @example Create a git location
12
- # Location.init(dependency, git: 'git://github.com/berkshelf/berkshelf.git')
12
+ # Location.init(dependency, git: 'https://github.com/berkshelf/berkshelf.git')
13
13
  #
14
14
  # @example Create a GitHub location
15
15
  # Location.init(dependency, github: 'berkshelf/berkshelf')
@@ -28,9 +28,9 @@ module Berkshelf
28
28
 
29
29
  private
30
30
 
31
- # Load the correct location from the given options.
32
- #
33
- # @return [Class, nil]
31
+ # Load the correct location from the given options.
32
+ #
33
+ # @return [Class, nil]
34
34
  def klass_from_options(options)
35
35
  options.each do |key, _|
36
36
  id = key.to_s.capitalize
@@ -37,28 +37,22 @@ module Berkshelf
37
37
  scratch_path = Pathname.new(Dir.mktmpdir)
38
38
 
39
39
  if cached?
40
- Dir.chdir(cache_path) do
41
- git %{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}
42
- end
40
+ git(%{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}, cwd: cache_path.to_s)
43
41
  else
44
42
  git %{clone #{uri} "#{cache_path}" --bare --no-hardlinks}
45
43
  end
46
44
 
47
- Dir.chdir(cache_path) do
48
- @revision ||= git %{rev-parse #{@rev_parse}}
49
- end
45
+ @revision ||= git(%{rev-parse #{@rev_parse}}, cwd: cache_path.to_s)
50
46
 
51
47
  # Clone into a scratch directory for validations
52
48
  git %{clone --no-checkout "#{cache_path}" "#{scratch_path}"}
53
49
 
54
50
  # Make sure the scratch directory is up-to-date and account for rel paths
55
- Dir.chdir(scratch_path) do
56
- git %{fetch --force --tags "#{cache_path}"}
57
- git %{reset --hard #{@revision}}
51
+ git(%{fetch --force --tags "#{cache_path}"}, cwd: scratch_path.to_s)
52
+ git(%{reset --hard #{@revision}}, cwd: scratch_path.to_s)
58
53
 
59
- if rel
60
- git %{filter-branch --subdirectory-filter "#{rel}" --force}
61
- end
54
+ if rel
55
+ git(%{filter-branch --subdirectory-filter "#{rel}" --force}, cwd: scratch_path.to_s)
62
56
  end
63
57
 
64
58
  # Validate the scratched path is a valid cookbook
@@ -9,7 +9,7 @@ module Berkshelf
9
9
  when :https
10
10
  options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
11
11
  when :git
12
- options[:git] = "git://#{HOST}/#{options.delete(:github)}.git"
12
+ options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
13
13
  else
14
14
  # if some bizarre value is provided, treat it as :https
15
15
  options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
@@ -511,8 +511,8 @@ module Berkshelf
511
511
  "#<Berkshelf::Lockfile #{Pathname.new(filepath).basename}, dependencies: #{dependencies.inspect}>"
512
512
  end
513
513
 
514
- # The class responsible for parsing the lockfile and turning it into a
515
- # useful data structure.
514
+ # The class responsible for parsing the lockfile and turning it into a
515
+ # useful data structure.
516
516
  class LockfileParser
517
517
  NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
518
518
  DEPENDENCY_PATTERN = /^ {2}#{NAME_VERSION}$/.freeze
@@ -599,9 +599,9 @@ module Berkshelf
599
599
 
600
600
  private
601
601
 
602
- # Parse a dependency line.
603
- #
604
- # @param [String] line
602
+ # Parse a dependency line.
603
+ #
604
+ # @param [String] line
605
605
  def parse_dependency(line)
606
606
  if line =~ DEPENDENCY_PATTERN
607
607
  name, version = $1, $2
@@ -615,9 +615,9 @@ module Berkshelf
615
615
  end
616
616
  end
617
617
 
618
- # Parse a graph line.
619
- #
620
- # @param [String] line
618
+ # Parse a graph line.
619
+ #
620
+ # @param [String] line
621
621
  def parse_graph(line)
622
622
  if line =~ DEPENDENCY_PATTERN
623
623
  name, version = $1, $2
@@ -631,7 +631,7 @@ module Berkshelf
631
631
  end
632
632
  end
633
633
 
634
- # The class representing an internal graph.
634
+ # The class representing an internal graph.
635
635
  class Graph
636
636
  include Enumerable
637
637
 
@@ -13,12 +13,12 @@ module Berkshelf
13
13
  #
14
14
  # @raise [String]
15
15
  # the +$stdout+ from the command
16
- def git(command, error = true)
16
+ def git(command, error = true, **kwargs)
17
17
  unless Berkshelf.which("git") || Berkshelf.which("git.exe") || Berkshelf.which("git.bat")
18
18
  raise GitNotInstalled.new
19
19
  end
20
20
 
21
- response = shell_out(%{git #{command}})
21
+ response = shell_out(%{git #{command}}, **kwargs)
22
22
 
23
23
  if response.error?
24
24
  raise GitCommandError.new(command, cache_path, response.stderr)