Skip to content

Commit c3a8607

Browse files
committed
Resolve code review comments
1 parent 2be4d7a commit c3a8607

File tree

2 files changed

+24
-142
lines changed

2 files changed

+24
-142
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ For more information on cleaning up the commits in a pull request, such as how t
107107

108108
#### Updating the change log
109109

110-
Any large changes that are made to a service must be reflected in the respecitve change log. This change log will allow customers to easily track what has been changed between releases of a service.
110+
Any public API changes that are made to a service must be reflected in the respecitve change log. This change log will allow customers to easily track what has been changed between releases of a service.
111111

112112
For ResourceManager services, the change log is located at `src\ResourceManager\SERVICE\ChangeLog.md`.
113113

tools/UpdateChangeLog.ps1

Lines changed: 23 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -88,63 +88,19 @@ be placed in the release notes instead.
8888
#>
8989
function UpdateModule([string]$PathToModule, [string[]]$ChangeLogContent)
9090
{
91-
# Get the content of the service psd1 file
92-
$content = Get-Content $PathToModule -Encoding UTF8
91+
$releaseNotes = @()
9392

94-
# The size of the new file will be everything in the array we got from
95-
# UpdateServiceChangeLog, except we exclude the last line (which is assumed to be blank)
96-
$size = $content.Length + $ChangeLogContent.Length - 1
97-
98-
# Create a new object with enough space for the old content plus the new changes made this release
99-
$newContent = New-Object string[] $size
100-
101-
$buffer = 0
102-
103-
for ($idx = 0; $idx -lt $content.Length; $idx++)
93+
if ($ChangeLogContent.Length -le 1)
10494
{
105-
# Once we reach the release notes section, we need to update the information
106-
if ($content[$idx] -like "*ReleaseNotes =*")
107-
{
108-
$end = $content[$idx].IndexOf("'")
109-
$newContent[$idx] = $content[$idx].Substring(0, $end)
110-
111-
# If there were no changes made this release, set the notes as the common code string
112-
if ($ChangeLogContent.Length -le 1)
113-
{
114-
$newContent[$idx] += "'Updated for common code changes'"
115-
}
116-
# If there were changes made this release, add the changes
117-
else
118-
{
119-
$newContent[$idx] += "'$($ChangeLogContent[0])"
120-
for ($tempBuffer = 1; $tempBuffer -lt $ChangeLogContent.Length - 1; $tempBuffer++)
121-
{
122-
$newContent[$idx + $tempBuffer] = $ChangeLogContent[$tempBuffer]
123-
124-
# If we are on the last line, add the apostrophe to end the string
125-
if (($tempBuffer + 1) -eq ($ChangeLogContent.Length -1))
126-
{
127-
$newContent[$idx + $tempBuffer] += "'"
128-
}
129-
}
130-
131-
# Update the buffer
132-
$buffer = $ChangeLogContent.Length - 2
133-
}
134-
135-
}
136-
# For all other lines in the psd1 file, add them to the new content array
137-
else
138-
{
139-
$newContent[$idx + $buffer] = $content[$idx]
140-
}
95+
$releaseNotes += "Updated for common code changes"
96+
}
97+
else
98+
{
99+
$releaseNotes += $ChangeLogContent
141100
}
142101

143-
# Update the service psd1 file to include all of the changes we made
144-
$result = $newContent -join "`r`n"
145-
$tempFile = Get-Item $PathToModule
146102

147-
[System.IO.File]::WriteAllText($tempFile.FullName, $result, [Text.Encoding]::UTF8)
103+
Update-ModuleManifest -Path $PathToModule -ReleaseNotes $releaseNotes
148104
}
149105

150106
<#
@@ -189,89 +145,7 @@ This function will use the psd1 file to grab the module version.
189145
#>
190146
function GetModuleVersion([string]$PathToModule)
191147
{
192-
# Get the content of the psd1 file
193-
$content = Get-Content $PathToModule -Encoding UTF8
194-
195-
# For each line of the file, check if we have found the module version
196-
for ($idx = 0; $idx -lt $content.Length; $idx++)
197-
{
198-
# If we have found the module version, grab the value and return it
199-
if ($content[$idx] -like "ModuleVersion*")
200-
{
201-
$start = $content[$idx].IndexOf("'") + 1
202-
203-
$end = $content[$idx].LastIndexOf("'")
204-
205-
$length = $end - $start
206-
207-
return $content[$idx].Substring($start, $length)
208-
}
209-
}
210-
211-
# Throw if we are unable to find the module version
212-
throw "Could not find module version for file $PathToModule"
213-
}
214-
215-
<#
216-
This function will clear the release notes for a psd1 file.
217-
#>
218-
function ClearReleaseNotes([string]$PathToModule)
219-
{
220-
# Get the contents of the psd1 file
221-
$content = Get-Content $PathToModule -Encoding UTF8
222-
223-
# This will keep track of the size of the current release notes
224-
$length = 0
225-
# This will let us know if we are currently iterating over the release notes
226-
$found = $False
227-
228-
# For each line of the file, look for the release notes and find the size
229-
for ($idx = 0; $idx -lt $content.Length; $idx++)
230-
{
231-
# If we have found the release notes section, switch the variable on
232-
if ($content[$idx] -like "*ReleaseNotes =*")
233-
{
234-
$found = $True
235-
}
236-
# If we have found the end of the release notes section, switch the variable off
237-
elseif ($content[$idx] -like "*End of PSData*")
238-
{
239-
$found = $false
240-
}
241-
# If we are currently iterating over release notes, increment the size
242-
elseif ($found)
243-
{
244-
$length++
245-
}
246-
}
247-
248-
# Determine the size of the file without the release notes
249-
$size = $content.Length - $length + 1
250-
251-
# Create a new object that will hold the contents of the new psd1 file
252-
$newContent = New-Object string[] $size
253-
254-
$buffer = 0
255-
256-
# For each line in the psd1 file, copy it over to the new psd1 file, but
257-
# make sure to skip the release notes
258-
for ($idx = 0; $idx -lt $newContent.Length; $idx++)
259-
{
260-
$newContent[$idx] = $content[$idx + $buffer]
261-
262-
# If we have found the release notes, set the buffer so we do not copy
263-
# them over to the new psd1 file
264-
if ($content[$idx] -like "*ReleaseNotes =*")
265-
{
266-
$buffer = $length - 1
267-
}
268-
}
269-
270-
# Update the psd1 file to include all of the changes we made
271-
$result = $newContent -join "`r`n"
272-
$tempFile = Get-Item $PathToModule
273-
274-
[System.IO.File]::WriteAllText($tempFile.FullName, $result, [Text.Encoding]::UTF8)
148+
return (Test-ModuleManifest -Path $PathToModule).Version.ToString()
275149
}
276150

277151
<#
@@ -294,8 +168,17 @@ function UpdateARMLogs([string]$PathToServices)
294168
{
295169
# Get the service folder
296170
$Service = Get-Item -Path "$($log.FullName)\.."
171+
172+
$serviceName = $Service.Name
173+
174+
if ($serviceName -eq "AzureBackup") { $serviceName = "Backup" }
175+
if ($serviceName -eq "AzureBatch") { $serviceName = "Batch" }
176+
177+
178+
179+
297180
# Get the psd1 file
298-
$Module = Get-Item -Path "$($Service.FullName)\*.psd1"
181+
$Module = Get-Item -Path "$PathToRepo\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.$serviceName\AzureRM.$serviceName.psd1"
299182

300183
# Get the path to the change log
301184
$PathToChangeLog = "$($log.FullName)"
@@ -332,9 +215,6 @@ function UpdateLog([string]$PathToChangeLog, [string]$PathToModule, [string]$Ser
332215
# Get the module version for ServiceManagement
333216
$ModuleVersion = GetModuleVersion -PathToModule $module.FullName
334217

335-
# Clear the release notes for ServiceManagement
336-
ClearReleaseNotes -PathToModule $module.FullName
337-
338218
# Update the change log and get the contents of the change log for the current release
339219
$changeLogContent = UpdateServiceChangeLog -PathToChangeLog $log.FullName -ModuleVersion $ModuleVersion
340220

@@ -366,18 +246,20 @@ if (!$PathToRepo)
366246
$PathToRepo = "$PSScriptRoot\.."
367247
}
368248

249+
Import-Module PowerShellGet
250+
369251
# Update all of the ResourceManager change logs
370252
$ResourceManagerResult = UpdateARMLogs -PathToServices $PathToRepo\src\ResourceManager
371253

372254
# Update the ServiceManagement change log
373255
$PathToChangeLog = "$PathToRepo\src\ServiceManagement\Services\Commands.Utilities\ChangeLog.md"
374-
$PathToModule = "$PathToRepo\src\ServiceManagement\Services\Commands.Utilities\Azure.psd1"
256+
$PathToModule = "$PathToRepo\src\Package\Debug\ServiceManagement\Azure\Azure.psd1"
375257

376258
$ServiceManagementResult = UpdateLog -PathToChangeLog $PathToChangeLog -PathToModule $PathToModule -Service "ServiceManagement"
377259

378260
# Update the Storage change log
379261
$PathToChangeLog = "$PathToRepo\src\Storage\ChangeLog.md"
380-
$PathToModule = "$PathToRepo\src\Storage\Azure.Storage.psd1"
262+
$PathToModule = "$PathToRepo\src\Package\Debug\Storage\Azure.Storage\Azure.Storage.psd1"
381263

382264
$StorageResult = UpdateLog -PathToChangeLog $PathToChangeLog -PathToModule $PathToModule -Service "Azure.Storage"
383265

0 commit comments

Comments
 (0)