puppetlabs/puppet_for_the_win — pull request #69 by haus (2014-07-11 20:35:59+00:00)
Title: (PE-4699) Ensure PEVERSION constant is defined

Previously, the windows rake task was transforming lib/puppet/version.rb from:

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION})"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION})"
else
PUPPETVERSION = '3.6.2'
end

to

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION}) (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise #{PEVERSION}) (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)"
else
PUPPETVERSION = '3.6.2 (Puppet Enterprise 3.3.0-rc2-409-gb3a28f9)'
end

Note that (Puppet Enterprise ..) is repeated twice for two of the
cases. This fortunately is not a problem, because the PEBuildFile and
PEVersion file are under '/opt/puppet' and don't exist on Windows.

Also note that PEVERSION is missing in the else case. This is problem
because the PE PMT requires the constant to be defined.

This commit changes the transformation to:

if File.readable? PEBuildFile and !File.zero? PEBuildFile
PEVERSION = File.new(PEBuildFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise 3.3.0)"
elsif File.readable? PEVersionFile and !File.zero? PEVersionFile
PEVERSION = File.new(PEVersionFile).gets.chomp
PUPPETVERSION = "3.6.2 (Puppet Enterprise 3.3.0)"
else
PEVERSION = '3.3.0'
PUPPETVERSION = '3.6.2 (Puppet Enterprise 3.3.0)'
end