Explorar o código

feat(git): Change the namespace for git to add hooksPath

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO %!s(int64=2) %!d(string=hai) anos
pai
achega
a7315f0328

+ 5 - 3
cookbooks/workstation/attributes/_git.rb

@@ -1,4 +1,5 @@
-default['workstation']['_git']['system'] = {
+default['workstation']['_git']['hooksPath'] = '~/.git-templates/hooks'
+default['workstation']['_git']['scope']['system'] = {
   'color.ui': true,
   'color.diff': 'auto',
   'color.status': 'auto',
@@ -22,10 +23,11 @@ default['workstation']['_git']['system'] = {
   'user.email': "jeremy@#{node['hostname']}",
   'user.name': 'Jeremy from WSL2',
   'pull.rebase': 'preserve',
+  'core.hooksPath': node['workstation']['_git']['hooksPath'],
 }
 
 # We don't use hash because keys such as "includeif.gitdir" are not uniq
-default['workstation']['_git']['global'] = {
+default['workstation']['_git']['scope']['global'] = {
   'core.sshcommand': '/usr/sbin/ssh-ident',
   'user.email': 'jeremy.mauro@gmail.com',
   'user.name': 'Jeremy MAURO',
@@ -40,7 +42,7 @@ default['workstation']['_git']['file_~/.gitconfig-personal'] = {
   'user.signingkey': 'FA2D8E280A6DD533',
 }
 
-default['workstation']['_git']['file_~/.gitconfig-work'] = {
+default['workstation']['_git']['scope']['file_~/.gitconfig-work'] = {
   'user.email': 'jmauro@aviatrix.com',
   'user.name': 'Jeremy MAURO',
 }

+ 5 - 1
cookbooks/workstation/recipes/_git.rb

@@ -12,7 +12,7 @@ include_recipe 'workstation::_ssh-ident'
 
 username = node['my_workstation']['default_user'].first[0]
 
-node['workstation']['_git'].each do |scope_git, git_options|
+node['workstation']['_git']['scope'].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'
@@ -26,3 +26,7 @@ node['workstation']['_git'].each do |scope_git, git_options|
     end
   end
 end
+
+directory node['workstation']['_git']['hooksPath'] do
+  recursive true
+end