Style: Add period in summary doc tags#8577
Merged
daxian-dbw merged 15 commits intoPowerShell:masterfrom Jan 5, 2019
Merged
Conversation
daxian-dbw
approved these changes
Jan 5, 2019
Member
daxian-dbw
left a comment
There was a problem hiding this comment.
I ran a script to validate the changes in this PR, and all look good :D Thanks @iSazonov!
CheckAddingPeriod.ps1
param(
[Parameter(Mandatory=$true)]
[string]
$PRUrl,
[switch]
$PassThru
)
enum DiffState {
None
FileInfo
DiffContent
}
[DiffState]$state = [DiffState]::None
$Log = @{}
$diffFile = Join-Path -Path $PSScriptRoot -ChildPath "diff.txt"
if (Test-Path -Path $diffFile) { Remove-Item -Path $diffFile -Force -ErrorAction Stop }
##
## .diff and .patch can be append in the end to get some raw content
##
$PRUrl += ".diff"
Invoke-WebRequest -Uri $PRUrl -OutFile $diffFile
$Script:ScanResult = $null
switch -Wildcard -File $diffFile
{
"diff --git *"
{
$state = [DiffState]::FileInfo
$fileName = ($_ -split " ")[-1].Substring(2)
if ($Script:ScanResult -ne $null -and
$Script:ScanResult["OriginalStrs"].Count -ne $Script:ScanResult["NewStrs"].Count)
{
throw "$($Script:ScanResult['FileName']) contains mismatched + and -"
}
if ($Log.ContainsKey($fileName))
{
throw "$fileName appeared twice in diff file. Something is wrong"
}
$Script:ScanResult = @{ FileName = $fileName; OriginalStrs = @(); NewStrs = @() }
$Log[$fileName] = $Script:ScanResult
}
"@@ * @@ *"
{
$state = [DiffState]::DiffContent
}
"-*"
{
if ($state -eq [DiffState]::DiffContent)
{
$old = $_.Substring(1)
$Script:ScanResult["OriginalStrs"] += $old
}
}
"+*"
{
if ($state -eq [DiffState]::DiffContent)
{
$new = $_.Substring(1)
$Script:ScanResult["NewStrs"] += $new
}
}
}
Write-Host -Object "$($Log.Count) files involved in this PR`n"
foreach ($result in $Log.Values)
{
$newStrs = $result["NewStrs"]
$originalStrs = $result["OriginalStrs"]
for ($i = 0; $i -lt $originalStrs.Length; $i++)
{
$oldString = $originalStrs[$i]
$newString = $newStrs[$i]
$afterReplace = $oldString.Trim() + "."
$afterProcess = $newString.TrimStart()
if (!$afterProcess.StartsWith("///") -or $afterReplace -cne $afterProcess)
{
Write-Error -Message @"
$($result['FileName']) - mismatch
Old: $oldString
New: $newString
"@
}
}
}
if ($PassThru) { return $Log }
Collaborator
Author
|
@daxian-dbw You could publish the script in gist. |
Member
|
The very first version of this script was published in gist years ago, at https://gist.github.com/daxian-dbw/3df8f9236a73a1d9b8c5cc913476d618
Well, I do wish we don't have huge PRs like this one, but it's inevitable for style changes 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Style fix: Add period in summary doc tags.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests