I am executing a git command in my Azure DevOps YAML pipeline to get changes between two commits like git diff commit1 commit2 --name-only
via a PowerShell script - see full code below:
Write-Information "git diff --name-only $git_event_before $git_event_after --diff-filter=ACM ""*.txt"""
$txt_files = @($(git diff --name-only $git_event_before $git_event_after --diff-filter=ACM "*.txt"))
$txt_files = $txt_files | ForEach-Object { Join-Path $root_path $_ | Get-Item }
if ($txt_files.Count -eq 0) {
Write-Error "Something went wrong, could not find any changed .txt files using the above 'git diff'"
}
This throws an error claiming no files were found.
However, if I execute the very same git diff
command locally where I do also have the repository synced, it returns the changed files as expected.
Do I need to manually update the repository that is already downloaded by the checkout-step of the pipeline ?