From 58cd98c817ec6548a1520698ebe391397571ad90 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 29 Jul 2023 12:07:05 +0100 Subject: [PATCH] Always fixup clone win_git repo owner --- library/win_git.ps1 | 17 +++++++++-------- roles/autohotkey/tasks/main.yaml | 4 ---- roles/obsidian/tasks/Windows.yaml | 4 ---- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/library/win_git.ps1 b/library/win_git.ps1 index 72b4ba9..7a57bba 100644 --- a/library/win_git.ps1 +++ b/library/win_git.ps1 @@ -127,14 +127,6 @@ function Invoke-GitClone { if ($result.rc -ne 0) { $module.FailJson($result.stderr) } - # Ensure the newly cloned repository has the correct owner - $userName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name - $idRef = [System.Security.Principal.NTAccount]::new($userName) - Get-Item $dest | foreach { ` - $_ ; $_ | Get-ChildItem -Force -Recurse ` - } | foreach { ` - $acl = $_ | Get-Acl; $acl.SetOwner($idRef); $_ | Set-Acl -AclObject $acl ` - } } function Invoke-GitCheckout { @@ -228,4 +220,13 @@ if ($recursive) { Invoke-GitSubmoduleUpdate $dest } +# Ensure the repository has the correct owner +$userName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name +$idRef = [System.Security.Principal.NTAccount]::new($userName) +Get-Item $dest | foreach { ` + $_ ; $_ | Get-ChildItem -Force -Recurse ` +} | foreach { ` + $acl = $_ | Get-Acl; $acl.SetOwner($idRef); $_ | Set-Acl -AclObject $acl ` +} + $module.ExitJson() diff --git a/roles/autohotkey/tasks/main.yaml b/roles/autohotkey/tasks/main.yaml index ac9c4dc..8f64b6d 100644 --- a/roles/autohotkey/tasks/main.yaml +++ b/roles/autohotkey/tasks/main.yaml @@ -9,10 +9,6 @@ repo: git@code.infektor.net:config/AutoHotKey.git dest: '{{autohotkey_repo_dir}}' branch: master -- win_owner: - path: '{{autohotkey_repo_dir}}' - user: Benie - recurse: true - name: create scheduled task win_scheduled_task: diff --git a/roles/obsidian/tasks/Windows.yaml b/roles/obsidian/tasks/Windows.yaml index fbc3ab6..c503809 100644 --- a/roles/obsidian/tasks/Windows.yaml +++ b/roles/obsidian/tasks/Windows.yaml @@ -12,7 +12,3 @@ repo: git@github.com:kbenzie/notes.git dest: '{{obsidian_notes_repo}}' branch: main -- win_owner: - path: '{{obsidian_notes_repo}}' - user: Benie - recurse: true