51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/pdk/util/puppet_version.rb', line 51
def fetch_puppet_dev(options = {})
return if options[:run] == :once && puppet_dev_fetched?
require 'pdk/util/git'
unless PDK::Util::Git.remote_repo? puppet_dev_path
if PDK::Util::Filesystem.exist? puppet_dev_path
PDK::Util::Filesystem.delete(puppet_dev_path) if PDK::Util::Filesystem.file? puppet_dev_path
PDK::Util::Filesystem.rm_rf(puppet_dev_path) if PDK::Util::Filesystem.directory? puppet_dev_path
end
PDK::Util::Filesystem.mkdir_p puppet_dev_path
clone_result = PDK::Util::Git.git('clone', DEFAULT_PUPPET_DEV_URL, puppet_dev_path)
return if clone_result[:exit_code].zero?
PDK.logger.error clone_result[:stdout]
PDK.logger.error clone_result[:stderr]
raise PDK::CLI::FatalError, format("Unable to clone git repository from '%{repo}'.", repo: DEFAULT_PUPPET_DEV_URL)
end
fetch_result = PDK::Util::Git.git('-C', puppet_dev_path, 'fetch', 'origin')
unless fetch_result[:exit_code].zero?
PDK.logger.error fetch_result[:stdout]
PDK.logger.error fetch_result[:stderr]
raise PDK::CLI::FatalError, format("Unable to fetch from git remote at '%{repo}'.", repo: DEFAULT_PUPPET_DEV_URL)
end
reset_result = PDK::Util::Git.git('-C', puppet_dev_path, 'reset', '--hard', "origin/#{DEFAULT_PUPPET_DEV_BRANCH}")
@puppet_dev_fetched = true
return if reset_result[:exit_code].zero?
PDK.logger.error reset_result[:stdout]
PDK.logger.error reset_result[:stderr]
raise PDK::CLI::FatalError, format("Unable to update git repository at '%{cachedir}'.", cachedir: puppet_dev_path)
end
|