Skip to content

Commit f8fb650

Browse files
authored
Prepare for the 2.2.0-beta2 release (#2241)
1 parent 8df5b6b commit f8fb650

File tree

5 files changed

+287
-4
lines changed

5 files changed

+287
-4
lines changed

MockPSConsole/MockPSConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
1414
<PackageReference Include="System.Xml.XDocument" version="4.3.0" />
1515
<PackageReference Include="System.Data.DataSetExtensions" version="4.5.0" />
16-
<PackageReference Include="Microsoft.CSharp" version="4.5.0" />
16+
<PackageReference Include="Microsoft.CSharp" version="4.7.0" />
1717
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
1818
</ItemGroup>
1919

PSReadLine/Changes.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
### [2.2.0-beta2] - 2021-02-23
2+
3+
- Update PSReadLine corresponding to the prediction interface updates (#2225)
4+
- Add white spaces to the emacs dispatch table (#2223)
5+
- Add the `SelectCommandArgument` bind-able function (#2222) (Thanks @ThePSAdmin for the idea!)
6+
- Move prediction functions to a new group (#2211)
7+
- Remove `LineIsMultiline` in favor of multi-line agnostic algorithms (#1125) (#2047) (Thanks @springcomp!)
8+
- Add the "Dynamic Help" feature to PSReadLine (#1777)
9+
- Prevent crash in `GotoFirstNonBlankOfLine` (#2050) (#2051) (Thanks @springcomp!)
10+
- Refactor the usage of `_clipboard` (#2022) (Thanks @springcomp!)
11+
- Make `d0` to delete to the start of the current logical line in a multiline buffer in VI mode (#2002) (Thanks @springcomp!)
12+
- Add github action to pre-triage new issues (#2117, #2118)
13+
- Highlight the install command in README.md (#2088) (Thanks @jiriurban21!)
14+
- Deleting backward to or until a character should preserve the character under the cursor (#2007) (Thanks @springcomp!)
15+
- Use `d^` to delete from the first non-blank character of a logical line (#2001) (Thanks @springcomp!)
16+
- Update nuget.config based on guidance (#2003)
17+
- Update the release build to use ESRP signing and unify the compliance job (#1983)
18+
- Add readonly modifier to some private fields (#1984)
19+
- Add argument selection handler to the sample profile (#1947) (Thanks @ThePSAdmin!)
20+
- Fix three issues with the menu completion (#1946)
21+
22+
[2.2.0-beta2]: https://github.com/PowerShell/PSReadLine/compare/v2.2.0-beta1...v2.2.0-beta2
23+
124
### Version 2.2.0-beta1
225

326
Changes:

PSReadLine/PSReadLine.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NoWarn>$(NoWarn);CA1416</NoWarn>
88
<AssemblyVersion>2.2.0.0</AssemblyVersion>
99
<FileVersion>2.2.0</FileVersion>
10-
<InformationalVersion>2.2.0-beta1</InformationalVersion>
10+
<InformationalVersion>2.2.0-beta2</InformationalVersion>
1111
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
1212
<TargetFrameworks>net461;net6.0</TargetFrameworks>
1313
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
@@ -16,7 +16,8 @@
1616

1717
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
1818
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
19-
<PackageReference Include="Microsoft.CSharp" version="4.5.0" />
19+
<PackageReference Include="Microsoft.CSharp" version="4.7.0" />
20+
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
2021
<ProjectReference Include="..\Polyfill\Polyfill.csproj" />
2122
</ItemGroup>
2223

test/PSReadLine.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageReference Include="System.Xml.XDocument" version="4.3.0" />
1919
<PackageReference Include="System.Data.DataSetExtensions" version="4.5.0" />
2020
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
21-
<PackageReference Include="Microsoft.CSharp" version="4.5.0" />
21+
<PackageReference Include="Microsoft.CSharp" version="4.7.0" />
2222
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
2323
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
2424
</ItemGroup>

tools/releaseTools.psm1

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
#requires -Version 6.0
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
class CommitNode {
6+
[string] $Hash
7+
[string[]] $Parents
8+
[string] $AuthorName
9+
[string] $AuthorGitHubLogin
10+
[string] $AuthorEmail
11+
[string] $Subject
12+
[string] $Body
13+
[string] $PullRequest
14+
[string] $ChangeLogMessage
15+
[string] $ThankYouMessage
16+
17+
CommitNode($hash, $parents, $name, $email, $subject, $body) {
18+
$this.Hash = $hash
19+
$this.Parents = $parents
20+
$this.AuthorName = $name
21+
$this.AuthorEmail = $email
22+
$this.Subject = $subject
23+
$this.Body = $body
24+
25+
if ($subject -match "\(#(\d+)\)$") {
26+
$this.PullRequest = $Matches[1]
27+
}
28+
}
29+
}
30+
31+
# These powershell team members don't use 'microsoft.com' for Github email or choose to not show their emails.
32+
# We have their names in this array so that we don't need to query GitHub to find out if they are powershell team members.
33+
$Script:powershell_team = @(
34+
"Robert Holt"
35+
"Travis Plunk"
36+
"Joey Aiello"
37+
)
38+
39+
# They are very active contributors, so we keep their email-login mappings here to save a few queries to Github.
40+
$Script:community_login_map = @{
41+
"[email protected]" = "springcomp"
42+
}
43+
44+
# Ignore dependency bumping bot (Dependabot):
45+
$Script:attribution_ignore_list = @(
46+
'dependabot[bot]@users.noreply.github.com'
47+
)
48+
49+
##############################
50+
#.SYNOPSIS
51+
#In the release workflow, the release branch will be merged back to master after the release is done,
52+
#and a merge commit will be created as the child of the release tag commit.
53+
#This cmdlet takes a release tag or the corresponding commit hash, find its child merge commit, and
54+
#return its metadata in this format: <merge-commit-hash>|<parent-commit-hashes>
55+
#
56+
#.PARAMETER LastReleaseTag
57+
#The last release tag
58+
#
59+
#.PARAMETER CommitHash
60+
#The commit hash of the last release tag
61+
#
62+
#.OUTPUTS
63+
#Return the metadata of the child merge commit, in this format: <merge-commit-hash>|<parent-commit-hashes>
64+
##############################
65+
function Get-ChildMergeCommit
66+
{
67+
[CmdletBinding(DefaultParameterSetName="TagName")]
68+
param(
69+
[Parameter(Mandatory, ParameterSetName="TagName")]
70+
[string]$LastReleaseTag,
71+
72+
[Parameter(Mandatory, ParameterSetName="CommitHash")]
73+
[string]$CommitHash
74+
)
75+
76+
$tag_hash = $CommitHash
77+
if ($PSCmdlet.ParameterSetName -eq "TagName") { $tag_hash = git rev-parse "$LastReleaseTag^0" }
78+
79+
## Get the merge commits that are reachable from 'HEAD' but not from the release tag
80+
$merge_commits_not_in_release_branch = git --no-pager log --merges "$tag_hash..HEAD" --format='%H||%P'
81+
## Find the child merge commit, whose parent-commit-hashes contains the release tag hash
82+
$child_merge_commit = $merge_commits_not_in_release_branch | Select-String -SimpleMatch $tag_hash
83+
return $child_merge_commit.Line
84+
}
85+
86+
##############################
87+
#.SYNOPSIS
88+
#Create a CommitNode instance to represent a commit.
89+
#
90+
#.PARAMETER CommitMetadata
91+
#The commit metadata. It's in this format:
92+
#<commit-hash>|<parent-hashes>|<author-name>|<author-email>|<commit-subject>
93+
#
94+
#.PARAMETER CommitMetadata
95+
#The commit metadata, in this format:
96+
#<commit-hash>|<parent-hashes>|<author-name>|<author-email>|<commit-subject>
97+
#
98+
#.OUTPUTS
99+
#Return the 'CommitNode' object
100+
##############################
101+
function New-CommitNode
102+
{
103+
param(
104+
[Parameter(ValueFromPipeline)]
105+
[ValidatePattern("^.+\|.+\|.+\|.+\|.+$")]
106+
[string]$CommitMetadata
107+
)
108+
109+
Process {
110+
$hash, $parents, $name, $email, $subject = $CommitMetadata.Split("||")
111+
$body = (git --no-pager show $hash -s --format=%b) -join "`n"
112+
return [CommitNode]::new($hash, $parents, $name, $email, $subject, $body)
113+
}
114+
}
115+
116+
##############################
117+
#.SYNOPSIS
118+
#Generate the draft change log.
119+
#
120+
#.PARAMETER LastReleaseTag
121+
#The last release tag
122+
#
123+
#.PARAMETER HasCherryPick
124+
#Indicate whether there are any commits in the last release branch that were cherry-picked from the master branch
125+
#
126+
#.PARAMETER Token
127+
#The authentication token to use for retrieving the GitHub user log-in names for external contributors
128+
#
129+
#.OUTPUTS
130+
#The generated change log draft.
131+
##############################
132+
function Get-ChangeLog
133+
{
134+
param(
135+
[Parameter(Mandatory = $true)]
136+
[string]$LastReleaseTag,
137+
138+
[Parameter(Mandatory = $true)]
139+
[string]$ThisReleaseTag,
140+
141+
[Parameter(Mandatory)]
142+
[string]$Token,
143+
144+
[Parameter()]
145+
[switch]$HasCherryPick
146+
)
147+
148+
$tag_hash = git rev-parse "$LastReleaseTag^0"
149+
$format = '%H||%P||%aN||%aE||%s'
150+
$header = @{"Authorization"="token $Token"}
151+
152+
# Find the merge commit that merged the release branch to master.
153+
$child_merge_commit = Get-ChildMergeCommit -CommitHash $tag_hash
154+
if($child_merge_commit)
155+
{
156+
$commit_hash, $parent_hashes = $child_merge_commit.Split("||")
157+
}
158+
# Find the other parent of the merge commit, which represents the original head of master right before merging.
159+
$other_parent_hash = ($parent_hashes -replace $tag_hash).Trim()
160+
161+
if ($HasCherryPick) {
162+
## Sometimes we need to cherry-pick some commits from the master branch to the release branch during the release,
163+
## and eventually merge the release branch back to the master branch. This will result in different commit nodes
164+
## in master branch that actually represent same set of changes.
165+
##
166+
## In this case, we cannot simply use the revision range "$tag_hash..HEAD" because it will include the original
167+
## commits in the master branch that were cherry-picked to the release branch -- they are reachable from 'HEAD'
168+
## but not reachable from the last release tag. Instead, we need to exclude the commits that were cherry-picked,
169+
## and only include the commits that are not in the last release into the change log.
170+
171+
# Find the commits that were only in the orginal master, excluding those that were cherry-picked to release branch.
172+
$new_commits_from_other_parent = git --no-pager log --first-parent --cherry-pick --right-only "$tag_hash...$other_parent_hash" --format=$format | New-CommitNode
173+
# Find the commits that were only in the release branch, excluding those that were cherry-picked from master branch.
174+
$new_commits_from_last_release = git --no-pager log --first-parent --cherry-pick --left-only "$tag_hash...$other_parent_hash" --format=$format | New-CommitNode
175+
# Find the commits that are actually duplicate but having different patch-ids due to resolving conflicts during the cherry-pick.
176+
$duplicate_commits = $null
177+
if($new_commits_from_last_release -and $new_commits_from_other_parent)
178+
{
179+
$duplicate_commits = Compare-Object $new_commits_from_last_release $new_commits_from_other_parent -Property PullRequest -ExcludeDifferent -IncludeEqual -PassThru
180+
}
181+
if ($duplicate_commits) {
182+
$duplicate_pr_numbers = @($duplicate_commits | ForEach-Object -MemberName PullRequest)
183+
$new_commits_from_other_parent = $new_commits_from_other_parent | Where-Object PullRequest -NotIn $duplicate_pr_numbers
184+
}
185+
186+
# Find the commits that were made after the merge commit.
187+
$new_commits_after_merge_commit = @(git --no-pager log --first-parent "$commit_hash..HEAD" --format=$format | New-CommitNode)
188+
$new_commits = $new_commits_after_merge_commit + $new_commits_from_other_parent
189+
} else {
190+
## No cherry-pick was involved in the last release branch.
191+
## Using a ref rang like "$tag_hash..HEAD" with 'git log' means getting the commits that are reachable from 'HEAD' but not reachable from the last release tag.
192+
193+
## We use '--first-parent' for 'git log'. It means for any merge node, only follow the parent node on the master branch side.
194+
## In case we merge a branch to master for a PR, only the merge node will show up in this way, the individual commits from that branch will be ignored.
195+
## This is what we want because the merge commit itself already represents the PR.
196+
197+
## First, we want to get all new commits merged during the last release
198+
$new_commits_during_last_release = @(git --no-pager log --first-parent "$tag_hash..$other_parent_hash" --format=$format | New-CommitNode)
199+
## Then, we want to get all new commits merged after the last release
200+
$new_commits_after_last_release = @(git --no-pager log --first-parent "$commit_hash..HEAD" --format=$format | New-CommitNode)
201+
## Last, we get the full list of new commits
202+
$new_commits = $new_commits_during_last_release + $new_commits_after_last_release
203+
}
204+
205+
foreach ($commit in $new_commits) {
206+
Write-Verbose "authorname: $($commit.AuthorName)"
207+
if ($commit.AuthorEmail.EndsWith("@microsoft.com") -or $powershell_team -contains $commit.AuthorName -or $Script:attribution_ignore_list -contains $commit.AuthorEmail) {
208+
$commit.ChangeLogMessage = "- {0}" -f (Get-ChangeLogMessage $commit.Subject)
209+
} else {
210+
if ($community_login_map.ContainsKey($commit.AuthorEmail)) {
211+
$commit.AuthorGitHubLogin = $community_login_map[$commit.AuthorEmail]
212+
} else {
213+
$uri = "https://api.github.com/repos/PowerShell/PSReadLine/commits/$($commit.Hash)"
214+
try{
215+
$response = Invoke-WebRequest -Uri $uri -Method Get -Headers $header -ErrorAction Ignore
216+
} catch{}
217+
if($response)
218+
{
219+
$content = ConvertFrom-Json -InputObject $response.Content
220+
$commit.AuthorGitHubLogin = $content.author.login
221+
$community_login_map[$commit.AuthorEmail] = $commit.AuthorGitHubLogin
222+
}
223+
}
224+
$commit.ChangeLogMessage = ("- {0} (Thanks @{1}!)" -f (Get-ChangeLogMessage $commit.Subject), $commit.AuthorGitHubLogin)
225+
$commit.ThankYouMessage = ("@{0}" -f ($commit.AuthorGitHubLogin))
226+
}
227+
}
228+
229+
# Write output
230+
231+
$version = $ThisReleaseTag.TrimStart('v')
232+
Write-Output "### [${version}] - $(Get-Date -Format yyyy-MM-dd)`n"
233+
234+
foreach ($commit in $new_commits) {
235+
Write-Output $commit.ChangeLogMessage
236+
}
237+
238+
Write-Output "`n[${version}]: https://github.com/PowerShell/PSReadLine/compare/${LastReleaseTag}...${ThisReleaseTag}`n"
239+
}
240+
241+
function Get-ChangeLogMessage
242+
{
243+
param($OriginalMessage)
244+
245+
switch -regEx ($OriginalMessage)
246+
{
247+
'^Merged PR (\d*): ' {
248+
return $OriginalMessage.replace($Matches.0,'') + " (Internal $($Matches.1))"
249+
}
250+
'^Build\(deps\): ' {
251+
return $OriginalMessage.replace($Matches.0,'')
252+
}
253+
default {
254+
return $OriginalMessage
255+
}
256+
}
257+
}
258+
259+
Export-ModuleMember -Function Get-ChangeLog

0 commit comments

Comments
 (0)