lib/onceover/testconfig.rb in onceover-3.0.5 vs lib/onceover/testconfig.rb in onceover-3.0.6

- old
+ new

@@ -133,13 +133,42 @@ end # We need to do the copy to a tempdir then move the tempdir to the # destination, just in case we get a recursive copy # TODO: Improve this to save I/O + + # We might need to exclude some files + # + # if we are using bundler to install gems below the controlrepo + # we don't wan two copies so exclude those + # + # If there are more situations like this we can add them to this array as + # full paths + excluded_files = [] + if ENV['GEM_HOME'] + logger.debug "Excluding #{ENV['GEM_HOME']} from controlrepo copy" + excluded_files << Dir.glob("#{ENV['GEM_HOME']}/**/*") + excluded_files.flatten! + end + + # Exclude the files we need to + controlrepo_files = Dir.glob("#{repo.root}/**/*") + files_to_copy = (controlrepo_files - excluded_files).delete_if { |path| Pathname(path).directory? } + folders_to_copy = (controlrepo_files - excluded_files).keep_if { |path| Pathname(path).directory? } + logger.debug "Creating temp dir as a staging directory for copying the controlrepo to #{repo.tempdir}" temp_controlrepo = Dir.mktmpdir('controlrepo') - FileUtils.cp_r(Dir["#{repo.root}/*"], "#{temp_controlrepo}") + + logger.debug "Creating directories under #{temp_controlrepo}" + FileUtils.mkdir_p(folders_to_copy.map { |folder| "#{temp_controlrepo}/#{(Pathname(folder).relative_path_from(Pathname(repo.root))).to_s}"}) + + logger.debug "Copying files to #{temp_controlrepo}" + files_to_copy.each do |file| + FileUtils.cp(file,"#{temp_controlrepo}/#{(Pathname(file).relative_path_from(Pathname(repo.root))).to_s}") + end FileUtils.mkdir_p("#{repo.tempdir}/#{repo.environmentpath}/production") + + logger.debug "Copying #{temp_controlrepo} to #{repo.tempdir}/#{repo.environmentpath}/production" FileUtils.cp_r(Dir["#{temp_controlrepo}/*"], "#{repo.tempdir}/#{repo.environmentpath}/production") FileUtils.rm_rf(temp_controlrepo) # Pull the trigger! If it's not already been pulled if repo.tempdir