Sha256: 5cf159e4905f708cd2ce8eb67df8e6b983ce9d8d7b124853766f65e504999732

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true
class Chef
  class Provider
    class GitClient
      class Windows < Chef::Provider::GitClient
        include Chef::DSL::IncludeRecipe

        provides :git_client, os: 'windows' if respond_to?(:provides)

        action :install do
          windows_package parsed_windows_display_name do
            action :install
            source parsed_windows_package_url
            checksum parsed_windows_package_checksum
            installer_type :inno
          end

          # Git is installed to Program Files (x86) on 64-bit machines and
          # 'Program Files' on 32-bit machines
          PROGRAM_FILES = ENV['ProgramFiles(x86)'] || ENV['ProgramFiles']
          GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze

          # COOK-3482 - windows_path resource doesn't change the current process
          # environment variables. Therefore, git won't actually be on the PATH
          # until the next chef-client run
          ruby_block 'Add Git Path' do
            block do
              ENV['PATH'] += ";#{GIT_PATH}"
            end
            not_if { ENV['PATH'] =~ /GIT_PATH/ }
            action :nothing
          end

          windows_path GIT_PATH do
            notifies :create, 'ruby_block[Add Git Path]', :immediately
            action :add
          end
        end

        action :delete do
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chef-12.8.1 acceptance/top-cookbooks/test_run/git/libraries/provider_git_client_windows.rb
chef-12.8.1-universal-mingw32 acceptance/top-cookbooks/test_run/git/libraries/provider_git_client_windows.rb