Skip to content

Commit ff3b41a

Browse files
authored
Harden OneFlow Scripts (#94)
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.
1 parent db35aaa commit ff3b41a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

OneFlow/Publish-Release.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,27 @@ Write-Information ((Get-ParsedBuildVersionXML -BuildInfo $buildInfo).GetEnumerat
2828

2929
# merging the tag to develop branch on the official repository triggers the official build and release of the NuGet Packages
3030
$tagName = Get-BuildVersionTag $buildInfo
31+
32+
# This will get the name of the remote matching $buildInfo['OfficialGitRemoteUrl'])
3133
$officialRemoteName = Get-GitRemoteName $buildInfo official
34+
35+
# This will get the first remote that is NOT the official repo remote URL
36+
# This assumes there is only one such named remote. (Usually 'origin')
3237
$forkRemoteName = Get-GitRemoteName $buildInfo fork
3338

39+
if([string]::IsNullOrWhiteSpace($officialRemoteName))
40+
{
41+
throw "Official (official) remote is not available"
42+
}
43+
44+
if([string]::IsNullOrWhiteSpace($forkRemoteName))
45+
{
46+
throw "Fork (origin) remote is not available"
47+
}
48+
49+
Write-Information "Official Remote Name: $officialRemoteName"
50+
Write-Information "Fork Remote Name: $forkRemoteName"
51+
3452
$releaseBranch = "release/$tagName"
3553
$officialReleaseBranch = "$officialRemoteName/$releaseBranch"
3654

OneFlow/Start-Release.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,26 @@ Param(
1818
)
1919
$buildInfo = Initialize-BuildEnvironment
2020

21+
# This will get the name of the remote matching $buildInfo['OfficialGitRemoteUrl'])
2122
$officialRemoteName = Get-GitRemoteName $buildInfo official
23+
24+
# This will get the first remote that is NOT the official repo remote URL
25+
# This assumes there is only one such named remote. (Usually 'origin')
2226
$forkRemoteName = Get-GitRemoteName $buildInfo fork
2327

28+
if([string]::IsNullOrWhiteSpace($officialRemoteName))
29+
{
30+
throw "Official (official) remote is not available"
31+
}
32+
33+
if([string]::IsNullOrWhiteSpace($forkRemoteName))
34+
{
35+
throw "Fork (origin) remote is not available"
36+
}
37+
38+
Write-Information "Official Remote Name: $officialRemoteName"
39+
Write-Information "Fork Remote Name: $forkRemoteName"
40+
2441
# create new local branch for the release
2542
$branchName = "release/$(Get-BuildVersionTag $buildInfo)"
2643
Write-Information "Creating release branch in local repo"

0 commit comments

Comments
 (0)