From b5a60768727a0b7d3cc50b363c6062253a2c83f1 Mon Sep 17 00:00:00 2001 From: Steven Maillet Date: Fri, 31 Oct 2025 15:02:59 -0700 Subject: [PATCH] Harden OneFlow Scripts Fixes #93 * Updates OneFlow scripts to validate BOTH remotes are present in the set of remotes known to git. - For normal GitHub use only 'origin' is set upon first clone, so a second (official) needs to be added manually. This is easy to ommit when first setting up a new machine. These scripts will now catch that. --- OneFlow/Publish-Release.ps1 | 18 ++++++++++++++++++ OneFlow/Start-Release.ps1 | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/OneFlow/Publish-Release.ps1 b/OneFlow/Publish-Release.ps1 index 735c282..bfd10ff 100644 --- a/OneFlow/Publish-Release.ps1 +++ b/OneFlow/Publish-Release.ps1 @@ -28,9 +28,27 @@ Write-Information ((Get-ParsedBuildVersionXML -BuildInfo $buildInfo).GetEnumerat # merging the tag to develop branch on the official repository triggers the official build and release of the NuGet Packages $tagName = Get-BuildVersionTag $buildInfo + +# This will get the name of the remote matching $buildInfo['OfficialGitRemoteUrl']) $officialRemoteName = Get-GitRemoteName $buildInfo official + +# This will get the first remote that is NOT the official repo remote URL +# This assumes there is only one such named remote. (Usually 'origin') $forkRemoteName = Get-GitRemoteName $buildInfo fork +if([string]::IsNullOrWhiteSpace($officialRemoteName)) +{ + throw "Official (official) remote is not available" +} + +if([string]::IsNullOrWhiteSpace($forkRemoteName)) +{ + throw "Fork (origin) remote is not available" +} + +Write-Information "Official Remote Name: $officialRemoteName" +Write-Information "Fork Remote Name: $forkRemoteName" + $releaseBranch = "release/$tagName" $officialReleaseBranch = "$officialRemoteName/$releaseBranch" diff --git a/OneFlow/Start-Release.ps1 b/OneFlow/Start-Release.ps1 index 9f6c3d8..0fe2e6f 100644 --- a/OneFlow/Start-Release.ps1 +++ b/OneFlow/Start-Release.ps1 @@ -18,9 +18,26 @@ Param( ) $buildInfo = Initialize-BuildEnvironment +# This will get the name of the remote matching $buildInfo['OfficialGitRemoteUrl']) $officialRemoteName = Get-GitRemoteName $buildInfo official + +# This will get the first remote that is NOT the official repo remote URL +# This assumes there is only one such named remote. (Usually 'origin') $forkRemoteName = Get-GitRemoteName $buildInfo fork +if([string]::IsNullOrWhiteSpace($officialRemoteName)) +{ + throw "Official (official) remote is not available" +} + +if([string]::IsNullOrWhiteSpace($forkRemoteName)) +{ + throw "Fork (origin) remote is not available" +} + +Write-Information "Official Remote Name: $officialRemoteName" +Write-Information "Fork Remote Name: $forkRemoteName" + # create new local branch for the release $branchName = "release/$(Get-BuildVersionTag $buildInfo)" Write-Information "Creating release branch in local repo"