Skip to content

Commit

Permalink
fix: Git clone -Since time period ( Fixes #277 )
Browse files Browse the repository at this point in the history
Co-authored-by: ninmonkey <[email protected]>
  • Loading branch information
James Brundage and ninmonkey committed Aug 24, 2024
1 parent 927343c commit bc0a50e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Extensions/Git.Clone.Input.UGit.Extension.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit bc0a50e

Please sign in to comment.