using namespace System.Collections.Generic

# the final command will be
# git clone --branch release/v7.4 --shallow-since=2024-07-07 https://github.com/PowerShell/PowerShell

$cloneUrl = 'https://github.com/PowerShell/PowerShell'
$Since = [datetime]::Now.AddDays(-30 )
$Branch = 'release/v7.4'
$binGit = Get-Command -Name 'git' -CommandType Application -ea 'stop' 
# this bypasses most aliases or functions named 'git'

[List[Object]] $gitArgs = @( ) # builds an empty generic list [List<object>]
$GitArgs.Add('clone')

if( $Branch ) { 
    $gitArgs.AddRange(@( 
        '--branch'
        $Branch
    ))
}
if( $Since ) { 
   $gitArgs.AddRange(@(
      '--shallow-since={0}' -f @( $Since.ToString('yyyy-MM-dd') )
   ))
}
$gitArgs.Add( $cloneUrl )

# final args?
$gitArgs | Join-String -sep ' ' -op 'git '
# outputs: git clone --branch release/v7.4 --shallow-since=2024-07-07 https://github.com/PowerShell/PowerShell

# to actually invoke the native command, uncomment this line
 # & $binGit @gitArgs