_git.rb 606 B

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