From 3f20cf8b69219981f5bf9c7dc51397187fb0295f Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Mon, 27 Nov 2023 21:56:51 +0000 Subject: [PATCH] Rename `-TargetRepo` to `-Repo` --- Generate-GitBranches.Tests.ps1 | 18 +++++++++--------- Generate-GitBranches.ps1 | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Generate-GitBranches.Tests.ps1 b/Generate-GitBranches.Tests.ps1 index a0e4f3ba..b057ef2f 100644 --- a/Generate-GitBranches.Tests.ps1 +++ b/Generate-GitBranches.Tests.ps1 @@ -17,7 +17,7 @@ Describe "Generate-GitBranches.ps1" { It "Parameter validation" { { cd $PSScriptRoot - & ./Generate-GitBranches.ps1 -TargetRepo '' -ErrorAction Stop + & ./Generate-GitBranches.ps1 -Repo '' -ErrorAction Stop } | Should -Throw } @@ -38,9 +38,9 @@ Describe "Generate-GitBranches.ps1" { It "Creates and updates branches of a same repo (dry-run) " { $currentRef = git rev-parse --short HEAD if ($LASTEXITCODE) { throw } - & ./Generate-GitBranches.ps1 -TargetRepo . -Pull -ErrorAction Stop -WhatIf 6>$null # Create + & ./Generate-GitBranches.ps1 -Repo . -Pull -ErrorAction Stop -WhatIf 6>$null # Create git checkout $currentRef - & ./Generate-GitBranches.ps1 -TargetRepo . -Pull -ErrorAction Stop -WhatIf 6>$null # Update + & ./Generate-GitBranches.ps1 -Repo . -Pull -ErrorAction Stop -WhatIf 6>$null # Update cd $sameRepo $branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' } @@ -50,9 +50,9 @@ Describe "Generate-GitBranches.ps1" { It "Creates and updates branches of a same repo" { $currentRef = git rev-parse --short HEAD if ($LASTEXITCODE) { throw } - & ./Generate-GitBranches.ps1 -TargetRepo . -Pull -ErrorAction Stop 6>$null # Create + & ./Generate-GitBranches.ps1 -Repo . -Pull -ErrorAction Stop 6>$null # Create git checkout $currentRef - & ./Generate-GitBranches.ps1 -TargetRepo . -Pull -ErrorAction Stop 6>$null # Update + & ./Generate-GitBranches.ps1 -Repo . -Pull -ErrorAction Stop 6>$null # Update cd $sameRepo $branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' } @@ -89,8 +89,8 @@ Describe "Generate-GitBranches.ps1" { } It "Creates and updates branches of a different repo (dry-run)" { - & $sourceRepo/Generate-GitBranches.ps1 -TargetRepo $differentRepo -ErrorAction Stop 6>$null -WhatIf # Create - & $sourceRepo/Generate-GitBranches.ps1 -TargetRepo $differentRepo -ErrorAction Stop 6>$null -WhatIf # Update + & $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -ErrorAction Stop 6>$null -WhatIf # Create + & $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -ErrorAction Stop 6>$null -WhatIf # Update cd $differentRepo $branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' } @@ -98,8 +98,8 @@ Describe "Generate-GitBranches.ps1" { } It "Creates and updates branches of a different repo" { - & $sourceRepo/Generate-GitBranches.ps1 -TargetRepo $differentRepo -ErrorAction Stop 6>$null # Create - & $sourceRepo/Generate-GitBranches.ps1 -TargetRepo $differentRepo -ErrorAction Stop 6>$null # Update + & $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -ErrorAction Stop 6>$null # Create + & $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -ErrorAction Stop 6>$null # Update cd $differentRepo $branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' } diff --git a/Generate-GitBranches.ps1 b/Generate-GitBranches.ps1 index 962aeff7..d7263d3c 100644 --- a/Generate-GitBranches.ps1 +++ b/Generate-GitBranches.ps1 @@ -3,26 +3,26 @@ # 3. To build a game, checkout to its branch, edit .env, mutate .trigger, commit and push # Examples: # # Create branches for all games (dry-run) -# ./Generate-GitBranches.ps1 -TargetRepo . -Pull -WhatIf +# ./Generate-GitBranches.ps1 -Repo . -Pull -WhatIf # # # Create branches for all games -# ./Generate-GitBranches.ps1 -TargetRepo . -Pull +# ./Generate-GitBranches.ps1 -Repo . -Pull # # # Create branches for specific game -# ./Generate-GitBranches.ps1 -TargetRepo . -Pull -GameEngine srcds -Game csgo +# ./Generate-GitBranches.ps1 -Repo . -Pull -GameEngine srcds -Game csgo # # # Update branches for all games -# ./Generate-GitBranches.ps1 -TargetRepo . -Pull -Push +# ./Generate-GitBranches.ps1 -Repo . -Pull -Push # # # Update branches for specific game -# ./Generate-GitBranches.ps1 -TargetRepo . -Pull -Push -GameEngine srcds -Game csgo +# ./Generate-GitBranches.ps1 -Repo . -Pull -Push -GameEngine srcds -Game csgo # [CmdletBinding(SupportsShouldProcess)] param( # Target repo path [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] - [string]$TargetRepo + [string]$Repo , # Whether to pull changes from remote repo before creating / updating branches [switch]$Pull @@ -125,13 +125,13 @@ try { } $sourceRef = { git rev-parse --abbrev-ref HEAD } | Execute-Command try { - $TargetRepo = { cd $TargetRepo; git rev-parse --show-toplevel; cd - } | Execute-Command -WhatIf:$false # Execute this even if -WhatIf is passed + $Repo = { cd $Repo; git rev-parse --show-toplevel; cd - } | Execute-Command -WhatIf:$false # Execute this even if -WhatIf is passed }catch { - throw "$TargetRepo is not a git repo. Create a repo using: git init -b master" + throw "$Repo is not a git repo. Create a repo using: git init -b master" } - $isSameRepo = if ($TargetRepo -eq $sourceRepo) { $true } else { $false } + $isSameRepo = if ($Repo -eq $sourceRepo) { $true } else { $false } - Push-Location $TargetRepo + Push-Location $Repo foreach ($g in $games) { $branch = "$( $g['game_platform'] )-$( $g['game_engine'] )-$( $g['game'] )"