_git.rb 689 B

1234567891011121314151617181920212223242526
  1. #
  2. # Cookbook:: workstation
  3. # Recipe:: _git
  4. #
  5. # Copyright:: 2022, The Authors, All Rights Reserved.
  6. include_recipe 'git'
  7. include_recipe 'workstation::_user'
  8. include_recipe 'workstation::_ssh-ident'
  9. node['workstation']['_git'].each do |scope_git, git_options|
  10. if scope_git.match(/^file_/)
  11. gitconfig_file = $' # String after the match (ref: https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Special+global+variables)
  12. scope_git = 'file'
  13. end
  14. git_options.each do |k, v|
  15. git_config k do
  16. value v.to_s
  17. scope scope_git
  18. user username if %w{global file}.include?(scope_git)
  19. config_file gitconfig_file if scope_git == 'file'
  20. end
  21. end
  22. end