Skip to content

Commit 7decfd4

Browse files
committed
fix(auto-pr): Fix git status detection
- Reverts: #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.
1 parent b9b4818 commit 7decfd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bin/auto-pr.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ hub diff --name-only | ForEach-Object {
185185

186186
# detect if file was staged, because it's not when only LF or CRLF have changed
187187
$status = execute 'hub status --porcelain -uno'
188-
$status = $status | Select-Object -First 1
189-
if ($status -and $status -match "^\x20*M\x20+.*$app.json") {
188+
$status = $status | Where-Object { $_ -match "M\s{2}.*$app.json" }
189+
if ($status -and $status.StartsWith('M ') -and $status.EndsWith("$app.json")) {
190190
execute "hub commit -m '${app}: Update to version $version'"
191191
} else {
192192
Write-Host "Skipping $app because only LF/CRLF changes were detected ..." -ForegroundColor Yellow

0 commit comments

Comments
 (0)