Skip to content

Commit

Permalink
Support non-expiring PATs
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-peterson committed Oct 4, 2024
1 parent 0565211 commit 96c2a10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/GitlabCli/GitlabCli.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '1.119.2'
ModuleVersion = '1.119.3'

RequiredModules = @('powershell-yaml')

Expand Down Expand Up @@ -27,7 +27,7 @@
ExternalModuleDependencies = @('powershell-yaml')
ReleaseNotes =
@'
* bugfix: Remove WhatIf from cmdlet that no longer supports it
* bugfix: support non-expiring PATs
'@
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/GitlabCli/PersonalAccessTokens.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function Get-GitlabPersonalAccessToken {
[CmdletBinding(DefaultParameterSetName='Default')]
param(
[Parameter(Position=0, ParameterSetName='Default')]
[Alias('Id')]
[string]
$TokenId,

Expand Down Expand Up @@ -110,11 +111,14 @@ function Get-GitlabPersonalAccessToken {
$Request.Query.last_used_before = $LastUsedBefore
}
Invoke-GitlabApi @Request | New-WrapperObject 'Gitlab.PersonalAccessToken' | ForEach-Object {
$ExpiresAt = [datetime]::Parse($_.ExpiresAt)
$_.PSObject.Properties.Remove('ExpiresAt')
$_ | Add-Member -PassThru -NotePropertyMembers @{
ExpiresAt = $ExpiresAt
if ($_.ExpiresAt) {
$ExpiresAt = [datetime]::Parse($_.ExpiresAt)
$_.PSObject.Properties.Remove('ExpiresAt')
$_ | Add-Member -NotePropertyMembers @{
ExpiresAt = $ExpiresAt
}
}
$_
} | Sort-Object LastUsedAtSortable -Descending
}

Expand Down

0 comments on commit 96c2a10

Please sign in to comment.