Skip to content

Commit

Permalink
updated to skip removed files in get-samplefolder
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoore-msft committed Aug 10, 2019
1 parent 877fb05 commit ffbe4ff
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/ci-scripts/Get-SampleFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ $ChangedFile = Invoke-Restmethod "$PRUri"
$FolderArray = @()
$ChangedFile | ForEach-Object {
Write-Output $_.blob_url
$CurrentPath = Split-Path (Join-Path -path $RepoRoot -ChildPath $_.filename)
if ($_.status -ne "removed") { # ignore deleted files, for example when a sample folder is renamed
$CurrentPath = Split-Path (Join-Path -path $RepoRoot -ChildPath $_.filename)

# File in root of repo - TODO: should we block this?
If ($CurrentPath -eq $RepoRoot) {
Write-Error "### Error ### The file $($_.filename) is in the root of the repository. A PR can only contain changes to files from a sample folder at this time."
}
Else {
# find metadata.json
while (!(Test-Path (Join-Path -path $CurrentPath -ChildPath "metadata.json")) -and $CurrentPath -ne $RepoRoot) {
$CurrentPath = Split-Path $CurrentPath # if it's not in the same folder as this file, search it's parent
}
# if we made it to the root searching for metadata.json write the error
# File in root of repo - TODO: should we block this?
If ($CurrentPath -eq $RepoRoot) {
Write-Error "### Error ### The scenario folder for $($_.filename) does not include a metadata.json file. Please add a metadata.json file to your scenario folder as part of the pull request."
Write-Error "### Error ### The file $($_.filename) is in the root of the repository. A PR can only contain changes to files from a sample folder at this time."
}
Else {
$FolderArray += $currentpath
# find metadata.json
while (!(Test-Path (Join-Path -path $CurrentPath -ChildPath "metadata.json")) -and $CurrentPath -ne $RepoRoot) {
$CurrentPath = Split-Path $CurrentPath # if it's not in the same folder as this file, search it's parent
}
# if we made it to the root searching for metadata.json write the error
If ($CurrentPath -eq $RepoRoot) {
Write-Error "### Error ### The scenario folder for $($_.filename) does not include a metadata.json file. Please add a metadata.json file to your scenario folder as part of the pull request."
}
Else {
$FolderArray += $currentpath
}
}
}
}
Expand Down

0 comments on commit ffbe4ff

Please sign in to comment.