From 7decfd4c107b8d8a59d7eedfe8a56e1801120c2f Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Fri, 2 Aug 2019 13:18:26 +0200 Subject: [PATCH] fix(auto-pr): Fix git status detection - Reverts: https://github.com/lukesampson/scoop/pull/3026 See https://git-scm.com/docs/git-status#_short_format If the file was modified it shows ` M` and `M ` means it's staged. Files only containing whitespaces don't get staged by `git add` and we only care about actually staged files. Since the order of the `git status`-output is not sorted anymore the `Select-Object -First 1` is useless and it now uses `Where-Object` to find the correct line. --- bin/auto-pr.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/auto-pr.ps1 b/bin/auto-pr.ps1 index e6386a7bc..3d2a15f35 100644 --- a/bin/auto-pr.ps1 +++ b/bin/auto-pr.ps1 @@ -185,8 +185,8 @@ hub diff --name-only | ForEach-Object { # detect if file was staged, because it's not when only LF or CRLF have changed $status = execute 'hub status --porcelain -uno' - $status = $status | Select-Object -First 1 - if ($status -and $status -match "^\x20*M\x20+.*$app.json") { + $status = $status | Where-Object { $_ -match "M\s{2}.*$app.json" } + if ($status -and $status.StartsWith('M ') -and $status.EndsWith("$app.json")) { execute "hub commit -m '${app}: Update to version $version'" } else { Write-Host "Skipping $app because only LF/CRLF changes were detected ..." -ForegroundColor Yellow