From 96c2a10382cc8021239b60b3ad4b2a005994fdb9 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Fri, 4 Oct 2024 11:42:08 -0700 Subject: [PATCH] Support non-expiring PATs --- src/GitlabCli/GitlabCli.psd1 | 4 ++-- src/GitlabCli/PersonalAccessTokens.psm1 | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/GitlabCli/GitlabCli.psd1 b/src/GitlabCli/GitlabCli.psd1 index 00b401c..a1b9941 100644 --- a/src/GitlabCli/GitlabCli.psd1 +++ b/src/GitlabCli/GitlabCli.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '1.119.2' + ModuleVersion = '1.119.3' RequiredModules = @('powershell-yaml') @@ -27,7 +27,7 @@ ExternalModuleDependencies = @('powershell-yaml') ReleaseNotes = @' -* bugfix: Remove WhatIf from cmdlet that no longer supports it +* bugfix: support non-expiring PATs '@ } } diff --git a/src/GitlabCli/PersonalAccessTokens.psm1 b/src/GitlabCli/PersonalAccessTokens.psm1 index 95b07cc..f2c094d 100644 --- a/src/GitlabCli/PersonalAccessTokens.psm1 +++ b/src/GitlabCli/PersonalAccessTokens.psm1 @@ -4,6 +4,7 @@ function Get-GitlabPersonalAccessToken { [CmdletBinding(DefaultParameterSetName='Default')] param( [Parameter(Position=0, ParameterSetName='Default')] + [Alias('Id')] [string] $TokenId, @@ -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 }