Skip to content

Commit b2ab52c

Browse files
authored
Merge pull request #105 from sqlcollaborative/development
0.6.1
2 parents d423d55 + b900ce3 commit b2ab52c

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

build/Get-PRHistory.ps1

+3-5
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,19 @@ if ($ApiKey) {
7272
}
7373
Invoke-RestMethod @RequestParams -Uri 'https://api.github.com/' | Out-String | Write-Verbose
7474
}
75+
$RequestParams = if ($AuthSession) { @{ WebSession = $AuthSession } } else { @{ } }
7576
$gitParams = @(
7677
'--no-pager'
7778
'log'
7879
'--first-parent'
7980
"$CommitID..$HeadCommitID"
8081
'--format="%H"'
81-
'--'
82-
'.'
83-
'":(exclude)*.md"'
8482
)
8583
$commits = & git @gitParams
8684

8785
$prs = @()
8886
foreach ($commit in $commits) {
89-
$result = Invoke-RestMethod @RequestParams -Uri "https://api.github.com/search/issues?q=$($commit)is%3Amerged"
87+
$result = Invoke-RestMethod @RequestParams -Uri "https://api.github.com/search/issues?q=$($commit)+is%3Amerged+is%3Apr"
9088
if ($result.total_count -gt 0) {
9189
$prs += $result.items | Sort-Object -Property score -Descending | Select-Object -First 1
9290
}
@@ -110,4 +108,4 @@ if ($Append) {
110108
else { $currentContent = @() }
111109
$mdTable + $currentContent | Set-Content -Path $Path
112110
}
113-
else { $mdTable | Set-Content -Path $Path }
111+
else { $mdTable | Set-Content -Path $Path }

docs/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Release notes for v0.6.1:
2+
- ### Files in subfolders are not being added when -Match is used (#104) by @nvarscar
3+
------
4+
* Folders are no longer filtered out by the -Match regex string
15
# Release notes for v0.6.0:
26
- ### Adding prescripts and postscripts (#91) by @nvarscar
37
------

internal/functions/Get-DbopsFile.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
)
1515
Write-PSFMessage -Level Debug -Message "Getting child items from $Item; Root defined as $Root"
1616
$fileItems = Get-ChildItem $Item.FullName
17-
if ($Match) { $fileItems = $fileItems | Where-Object Name -match ($Match -join '|') }
1817
foreach ($childItem in $fileItems) {
1918
if ($childItem.PSIsContainer) {
2019
if ($Recurse) { Select-DbopsFile -Item (Get-Item $childItem.FullName) -Root $Root }
2120
}
2221
else {
22+
if ($Match -and $childItem.Name -notmatch ($Match -join '|')) { continue }
2323
if ($Relative) {
2424
$pkgPath = Resolve-Path $childItem.FullName -Relative
2525
}

tests/Add-DBOBuild.Tests.ps1

+19-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Describe "Add-DBOBuild tests" -Tag $commandName, UnitTests {
192192
$testResults.Name | Should Be (Split-Path $packageNameTest -Leaf)
193193
Test-Path $packageNameTest | Should Be $true
194194
$scripts = $testResults.GetBuild('2.0').Scripts
195-
Join-PSFPath -Normalize 'content\2.0' ((Resolve-Path $v2scripts -Relative) -replace '^\.\\|^\.\/', '')| Should BeIn $scripts.GetPackagePath()
195+
Join-PSFPath -Normalize 'content\2.0' ((Resolve-Path $v2scripts -Relative) -replace '^\.\\|^\.\/', '') | Should BeIn $scripts.GetPackagePath()
196196
Join-PSFPath -Normalize 'content\2.0\1.sql' | Should Not BeIn $scripts.GetPackagePath()
197197
$items = Get-ArchiveItem $packageNameTest
198198
Join-PSFPath -Normalize 'content\1.0\1.sql' | Should BeIn $items.Path
@@ -204,7 +204,7 @@ Describe "Add-DBOBuild tests" -Tag $commandName, UnitTests {
204204
$testResults.Name | Should Be (Split-Path $packageNameTest -Leaf)
205205
Test-Path $packageNameTest | Should Be $true
206206
$scripts = $testResults.GetBuild('2.0').Scripts
207-
Join-PSFPath -Normalize 'content\2.0' ($v2scripts -replace ':', '')| Should BeIn $scripts.GetPackagePath()
207+
Join-PSFPath -Normalize 'content\2.0' ($v2scripts -replace ':', '') | Should BeIn $scripts.GetPackagePath()
208208
Join-PSFPath -Normalize 'content\2.0\1.sql' | Should Not BeIn $scripts.GetPackagePath()
209209
$items = Get-ArchiveItem $packageNameTest
210210
Join-PSFPath -Normalize 'content\1.0\1.sql' | Should BeIn $items.Path
@@ -242,6 +242,22 @@ Describe "Add-DBOBuild tests" -Tag $commandName, UnitTests {
242242
Join-PSFPath -Normalize 'content\2.0\2.sql' | Should BeIn $items.Path
243243
Join-PSFPath -Normalize 'content\2.0\3.sql' | Should Not BeIn $items.Path
244244
}
245+
It "Should add only matched files from a recursive folder" {
246+
$testResults = Add-DBOBuild -ScriptPath $noRecurseFolder\* -Name $packageNameTest -Build 2.0 -Match '2\.sql'
247+
$testResults | Should Not Be $null
248+
$testResults.Name | Should Be (Split-Path $packageNameTest -Leaf)
249+
Test-Path $packageNameTest | Should Be $true
250+
$scripts = $testResults.GetBuild('2.0').Scripts
251+
$scripts | Should -Not -BeNullOrEmpty
252+
Join-PSFPath -Normalize 'content\2.0\success\1.sql' | Should Not BeIn $scripts.GetPackagePath()
253+
Join-PSFPath -Normalize 'content\2.0\success\2.sql' | Should BeIn $scripts.GetPackagePath()
254+
Join-PSFPath -Normalize 'content\2.0\success\3.sql' | Should Not BeIn $scripts.GetPackagePath()
255+
$items = Get-ArchiveItem $packageNameTest
256+
Join-PSFPath -Normalize 'content\1.0\1.sql' | Should BeIn $items.Path
257+
Join-PSFPath -Normalize 'content\2.0\success\1.sql' | Should Not BeIn $items.Path
258+
Join-PSFPath -Normalize 'content\2.0\success\2.sql' | Should BeIn $items.Path
259+
Join-PSFPath -Normalize 'content\2.0\success\3.sql' | Should Not BeIn $items.Path
260+
}
245261
}
246262
Context "negative tests" {
247263
BeforeAll {
@@ -267,7 +283,7 @@ Describe "Add-DBOBuild tests" -Tag $commandName, UnitTests {
267283
$errorResult.Exception.Message -join ';' | Should BeLike '*Incorrect package format*'
268284
}
269285
It "should throw error when package zip does not exist" {
270-
{ Add-DBOBuild -Name ".\nonexistingpackage.zip" -ScriptPath $v1scripts -ErrorAction Stop} | Should Throw
286+
{ Add-DBOBuild -Name ".\nonexistingpackage.zip" -ScriptPath $v1scripts -ErrorAction Stop } | Should Throw
271287
}
272288
It "should throw error when path cannot be resolved" {
273289
try {

0 commit comments

Comments
 (0)