Always fixup clone win_git repo owner

This commit is contained in:
Kenneth Benzie 2023-07-29 12:07:05 +01:00
parent 3b312e6f9a
commit 58cd98c817
3 changed files with 9 additions and 16 deletions

View File

@ -127,14 +127,6 @@ function Invoke-GitClone {
if ($result.rc -ne 0) { if ($result.rc -ne 0) {
$module.FailJson($result.stderr) $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 { function Invoke-GitCheckout {
@ -228,4 +220,13 @@ if ($recursive) {
Invoke-GitSubmoduleUpdate $dest 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() $module.ExitJson()

View File

@ -9,10 +9,6 @@
repo: git@code.infektor.net:config/AutoHotKey.git repo: git@code.infektor.net:config/AutoHotKey.git
dest: '{{autohotkey_repo_dir}}' dest: '{{autohotkey_repo_dir}}'
branch: master branch: master
- win_owner:
path: '{{autohotkey_repo_dir}}'
user: Benie
recurse: true
- name: create scheduled task - name: create scheduled task
win_scheduled_task: win_scheduled_task:

View File

@ -12,7 +12,3 @@
repo: git@github.com:kbenzie/notes.git repo: git@github.com:kbenzie/notes.git
dest: '{{obsidian_notes_repo}}' dest: '{{obsidian_notes_repo}}'
branch: main branch: main
- win_owner:
path: '{{obsidian_notes_repo}}'
user: Benie
recurse: true