123456789101112131415161718192021222324252627282930313233343536373839 |
- #
- # Cookbook:: workstation
- # Recipe:: _git
- #
- # Copyright:: 2022, The Authors, All Rights Reserved.
- include_recipe 'git'
- username, properties = node['my_workstation']['default_user'].first
- user username do
- properties.each do |property, value|
- send(property, value)
- end
- end
- user_repo_directory = ::File.join(properties['home'], 'repo')
- directory user_repo_directory do
- owner username
- group username
- recursive true
- end
- include_recipe 'workstation::_ssh-ident'
- node['workstation']['_git'].each do |scope_git, git_options|
- if scope_git.match(/^file_/)
- gitconfig_file = $' # String after the match (ref: https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Special+global+variables)
- scope_git = 'file'
- end
- git_options.each do |k, v|
- git_config k do
- value v.to_s
- scope scope_git
- user username if %w{global file}.include?(scope_git)
- config_file gitconfig_file if scope_git == 'file'
- end
- end
- end
|