File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,20 @@ function Get-ChangeLog
151151 [Parameter (Mandatory = $true )]
152152 [string ]$ThisReleaseTag ,
153153
154- [Parameter (Mandatory )]
154+ [Parameter (Mandatory = $false )]
155155 [string ]$Token ,
156156
157157 [Parameter ()]
158158 [switch ]$HasCherryPick
159159 )
160160
161+ if (-not $Token ) {
162+ $Token = Get-GHDefaultAuthToken
163+ if (-not $Token ) {
164+ throw " No GitHub Auth Token provided"
165+ }
166+ }
167+
161168 $tag_hash = git rev- parse " $LastReleaseTag ^0"
162169 $format = ' %H||%P||%aN||%aE||%s'
163170 $header = @ {" Authorization" = " token $Token " }
@@ -361,6 +368,29 @@ function Get-ChangeLog
361368 Write-Output " [${version} ]: https://github.com/PowerShell/PowerShell/compare/${LastReleaseTag} ...${ThisReleaseTag} `n "
362369}
363370
371+ function Get-GHDefaultAuthToken {
372+ $IsGHCLIInstalled = $false
373+ if (Get-command - CommandType Application - Name gh - ErrorAction SilentlyContinue) {
374+ $IsGHCLIInstalled = $true
375+ } else {
376+ Write-Error - Message " GitHub CLI is not installed. Please install it from https://cli.github.com/" - ErrorAction Stop
377+ }
378+
379+ if ($IsGHCLIInstalled ) {
380+ try {
381+ $Token = & gh auth token
382+ } catch {
383+ Write-Error - Message " Please login to GitHub CLI using 'gh auth login'"
384+ }
385+ }
386+
387+ if (-not $Token ) {
388+ $Token = Read-Host - Prompt " Enter GitHub Auth Token"
389+ }
390+
391+ return $Token
392+ }
393+
364394function PrintChangeLog ($clSection , $sectionTitle , [switch ] $Compress ) {
365395 if ($clSection.Count -gt 0 ) {
366396 " ### $sectionTitle `n "
You can’t perform that action at this time.
0 commit comments