_git.rb 634 B

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