Skip to content

Add ADS insiders gallery file to update script #2038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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