Skip to content

Commit

Permalink
Add ADS insiders gallery file to update script (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Holt authored and TylerLeonhardt committed Jun 25, 2019
1 parent 90e9e24 commit c9950b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
15 changes: 13 additions & 2 deletions tools/GitHubTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ function Copy-GitRepository
$Remotes,

[switch]
$Clobber
$Clobber,

[switch]
$PullUpstream,

[switch]
$UpdateOrigin
)

$Destination = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Destination)
Expand Down Expand Up @@ -101,9 +107,14 @@ function Copy-GitRepository
Exec { git remote add $remote $Remotes[$remote] }
}

if ($remote['upstream'])
if ($PullUpstream -and $remote['upstream'])
{
Exec { git pull upstream $CloneBranch }

if ($UpdateOrigin)
{
Exec { git push origin "+$CloneBranch"}
}
}

if ($CheckoutBranch)
Expand Down
46 changes: 28 additions & 18 deletions tools/postReleaseScripts/updateAzureDataStudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ param(
$ExtensionVersion,

[Parameter()]
[string]
$GalleryFileName = 'extensionsGallery.json',
[string[]]
$GalleryFileName = ('extensionsGallery.json','extensionsGallery-insider.json'),

[Parameter()]
[string]
Expand Down Expand Up @@ -213,26 +213,32 @@ function UpdateGalleryFile
[version]
$ExtensionVersion,

[Parameter()]
[string]
$GalleryFilePath = './extensionsGallery-insider.json'
[Parameter(Mandatory, ValueFromPipeline)]
[string[]]
$GalleryFilePath
)

# Create a new PowerShell extension entry
$powershellEntry = NewPowerShellExtensionEntry -ExtensionVersion $ExtensionVersion
$entryStr = ConvertTo-IndentedJson $powershellEntry -IndentChar "`t" -IndentWidth 1
process
{
foreach ($galleryFile in $GalleryFilePath)
{
# Create a new PowerShell extension entry
$powershellEntry = NewPowerShellExtensionEntry -ExtensionVersion $ExtensionVersion
$entryStr = ConvertTo-IndentedJson $powershellEntry -IndentChar "`t" -IndentWidth 1

# Find the position in the existing file where the PowerShell extension should go
$galleryFileContent = Get-Content -Raw $GalleryFilePath
$span = FindPSExtensionJsonSpan -GalleryExtensionFileContent $galleryFileContent
$startOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.Start.Line -Column $span.Start.Column
$endOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.End.Line -StartLine $span.Start.Line -Column $span.End.Column -InitialOffset $startOffset
# Find the position in the existing file where the PowerShell extension should go
$galleryFileContent = Get-Content -Raw $GalleryFilePath
$span = FindPSExtensionJsonSpan -GalleryExtensionFileContent $galleryFileContent
$startOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.Start.Line -Column $span.Start.Column
$endOffset = Get-StringOffsetFromSpan -String $galleryFileContent -EndLine $span.End.Line -StartLine $span.Start.Line -Column $span.End.Column -InitialOffset $startOffset

# Create the new file contents with the inserted segment
$newGalleryFileContent = New-StringWithSegment -String $galleryFileContent -NewSegment $entryStr -StartIndex $startOffset -EndIndex ($endOffset+1) -AutoIndent
# Create the new file contents with the inserted segment
$newGalleryFileContent = New-StringWithSegment -String $galleryFileContent -NewSegment $entryStr -StartIndex $startOffset -EndIndex ($endOffset+1) -AutoIndent

# Write out the new entry
Set-Content -Path $GalleryFilePath -Value $newGalleryFileContent -Encoding utf8NoBOM -NoNewline
# Write out the new entry
Set-Content -Path $GalleryFilePath -Value $newGalleryFileContent -Encoding utf8NoBOM -NoNewline
}
}
}

$repoLocation = Join-Path ([System.IO.Path]::GetTempPath()) 'ads-temp-checkout'
Expand All @@ -243,13 +249,17 @@ $cloneParams = @{
CloneBranch = 'release/extensions'
CheckoutBranch = $branchName
Clobber = $true
PullUpstream = $true
UpdateOrigin = $true
Remotes = @{
upstream = 'https://github.com/Microsoft/AzureDataStudio'
}
}
Copy-GitRepository @cloneParams

UpdateGalleryFile -ExtensionVersion $ExtensionVersion -GalleryFilePath "$repoLocation/$GalleryFileName"
$GalleryFileName |
ForEach-Object { "$repoLocation/$_" } |
UpdateGalleryFile -ExtensionVersion $ExtensionVersion

Submit-GitChanges -RepositoryLocation $repoLocation -File $GalleryFileName -Branch $branchName -Message "Update PS extension to v$ExtensionVersion"

Expand Down

0 comments on commit c9950b0

Please sign in to comment.