Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Sep 27, 2023
1 parent 7998b78 commit a8a376f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Generate-GitBranches.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Describe "Generate-GitBranches.ps1" {
$branches.Count | Should -Be 0
}

It "Creates and updates branches of this same repo" {
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
Expand Down
15 changes: 10 additions & 5 deletions Generate-GitBranches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,16 @@ function Get-EnvFileKv ($file, $branch) {

# Create new branch, remove all files except .git, create .trigger file, create .gitlab-ci.yml, commit files
try {
$sourceRepo = { cd $PSScriptRoot; git rev-parse --show-toplevel; cd - } | Execute-Command -ErrorAction SilentlyContinue -WhatIf:$false
if ($LASTEXITCODE) { throw "$PSScriptRoot is not a git repo" }

$TargetRepo = { cd $TargetRepo; git rev-parse --show-toplevel; cd - } | Execute-Command -ErrorAction SilentlyContinue -WhatIf:$false
if ($LASTEXITCODE) { throw "$TargetRepo is not a git repo" }
try {
$sourceRepo = { cd $PSScriptRoot; git rev-parse --show-toplevel; cd - } | Execute-Command -WhatIf:$false # -WhatIf:$false means execute this even if -WhatIf is passed
}catch {
throw "$PSScriptRoot is not a git repo"
}
try {
$TargetRepo = { cd $TargetRepo; git rev-parse --show-toplevel; cd - } | Execute-Command -WhatIf:$false # -WhatIf:$false means execute this even if -WhatIf is passed
}catch {
throw "$TargetRepo is not a git repo"
}

$isSameRepo = if ($TargetRepo -eq $sourceRepo) { $true } else { $false }

Expand Down

0 comments on commit a8a376f

Please sign in to comment.