_git.rb 840 B

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