Skip to content

Commit c5112fd

Browse files
committed
Fix condition in Get-CheckoutState
1 parent 8797348 commit c5112fd

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

extension/BuildPhpExtension/private/Get-CheckoutState.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ Function Get-CheckoutState {
1919
$checkout_state = $true;
2020
if([string]::IsNullOrWhiteSpace($Repository) -or -not(Test-Path .git)) {
2121
$checkout_state = $false
22-
}
23-
try {
24-
$originUrl = git remote get-url origin 2>$null
25-
if($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($originUrl)) {
22+
} else {
23+
try {
24+
$originUrl = git remote get-url origin 2> $null
25+
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($originUrl)) {
26+
$checkout_state = $false
27+
} else {
28+
$checkout_state = ($originUrl -match "(^|[:/])$([regex]::Escape($Repository) )(\.git)?$")
29+
}
30+
}
31+
catch {
2632
$checkout_state = $false
2733
}
28-
$checkout_state = ($originUrl -match "(^|[:/])$([regex]::Escape($Repository))(\.git)?$")
29-
} catch {
30-
$checkout_state = $false
3134
}
3235
$checkout_state = $checkout_state.ToString().ToLowerInvariant()
3336
if($null -ne $env:GITHUB_OUTPUT) {

0 commit comments

Comments
 (0)