Refactor verbose logging to debug level for token information; enhance Get-GiteaChildItem to handle LFS pointer details and update download URLs.

This commit is contained in:
2025-04-25 15:03:33 -04:00
parent 0c40d07bcd
commit dfb34f240b

View File

@@ -169,7 +169,7 @@ Function Get-GiteaFileContent {
Write-Verbose "repoOwner: $repoOwner"
Write-Verbose "repoName: $repoName"
Write-Verbose "branch: $branch"
Write-Verbose "token: $token"
Write-Debug "Token: $token"
Write-Verbose "decode: $decode"
$headers = @{
@@ -279,7 +279,7 @@ Function Get-GiteaLFSConfiguration {
Write-Verbose "giteaURL: $giteaURL"
Write-Verbose "repoOwner: $repoOwner"
Write-Verbose "repoName: $repoName"
Write-Verbose "token: $token"
Write-Debug "Token: $token"
$filePath = ".gitattributes"
@@ -389,7 +389,7 @@ Function Invoke-GiteaFileDownload {
}
Write-Verbose "Parameters:"
Write-Verbose "token: $token (length: $(if($token){$token.Length}else{0}))"
Write-Debug "Token: $token (length: $(if($token){$token.Length}else{0}))"
Write-Verbose "PreserveRelativePath: $PreserveRelativePath"
# Create a WebClient to be reused
@@ -645,7 +645,7 @@ Function Get-GiteaChildItem {
Write-Verbose "repoOwner: $repoOwner"
Write-Verbose "repoName: $repoName"
Write-Verbose "Path: $Path"
Write-Verbose "token: $token"
Write-Debug "Token: $token"
Write-Verbose "File: $File"
$headers = @{
@@ -698,6 +698,15 @@ Function Get-GiteaChildItem {
}
if ($isLFS) {
$item.type = "lfs"
# Save the original download URL for LFS pointers to be used to populate the size and sha fields
$GitLFSPointerURL = $item.download_url
# Use the Gitea API to get the LFS pointer details
$lfsPointerResponse = Invoke-RestMethod -Uri $GitLFSPointerURL -Method Get -Headers $headers -ErrorAction Stop
Write-Debug "LFS Pointer Response: $($lfsPointerResponse | ConvertTo-Json -Depth 1 -Compress)"
# Update the item with the LFS pointer details
$item.size = $lfsPointerResponse.size
$item.sha = $lfsPointerResponse.sha
# Set the download URL to the media endpoint for LFS files to download the actual file
$item.download_url = "$giteaURL/api/v1/repos/$repoOwner/$repoName/media/$($item.path)"
}