From bc0a50ef926b0c17e2d24c82bd18dbfc60b55fec Mon Sep 17 00:00:00 2001 From: James Brundage <@github.com> Date: Sat, 24 Aug 2024 13:43:08 -0700 Subject: [PATCH] fix: Git clone -Since time period ( Fixes #277 ) Co-authored-by: ninmonkey --- Extensions/Git.Clone.Input.UGit.Extension.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Extensions/Git.Clone.Input.UGit.Extension.ps1 b/Extensions/Git.Clone.Input.UGit.Extension.ps1 index 869a0852..e556abc5 100644 --- a/Extensions/Git.Clone.Input.UGit.Extension.ps1 +++ b/Extensions/Git.Clone.Input.UGit.Extension.ps1 @@ -40,7 +40,7 @@ $Depth, # Create a shallow clone with a history after the specified time. [Parameter(ValueFromPipelineByPropertyName)] -[Datetime] +[string] $Since, # One or more filters @@ -73,7 +73,15 @@ if ($NoCheckout) {'--no-checkout'} if ($Sparse) {'--sparse'} -if ($Since) {"--shallow-since=$($Since.ToString('o'))"} +if ($Since) { + if ($since -is [DateTime]) { + "--shallow-since=$($Since.ToString('o'))" + } elseif ($since -match '^\d+') { + "--shallow-since=$since" + } else { + Write-Warning "-Since must be a date or a number followed by a date unit." + } +} if ($filter) { foreach ($gitFilter in $filter) {