1 Commits
1.4.3 ... 1.4.4

Author SHA1 Message Date
edb1501f40 Bump module version to 1.4.4 and enhance Invoke-GiteaFileDownload to handle LFS file downloads with type inference and properly format file path based on API URL
All checks were successful
Publish Powershell Module to Gitea Repository / test (push) Successful in 10s
Publish Powershell Module to Gitea Repository / deploy (push) Successful in 31s
2025-05-27 12:38:58 -04:00
2 changed files with 18 additions and 6 deletions

View File

@@ -12,7 +12,7 @@
RootModule = 'PS-GiteaUtilities.psm1' RootModule = 'PS-GiteaUtilities.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '1.4.3' ModuleVersion = '1.4.4'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()

View File

@@ -410,8 +410,12 @@ Function Invoke-GiteaFileDownload {
} }
process { process {
# If type is not provided, check for any hints for cases such as LFS where a type can be inferred and special handling is needed
If($downloadURL -match "/api/v1/repos/[^/]+/[^/]+/media/") {
$type = "lfs"
}
Write-Verbose "Type: $type" Write-Verbose "Type: $type"
# Handle the type parameter # Handle the type parameter
# Skip directories and provide a verbose message # Skip directories and provide a verbose message
@@ -447,10 +451,18 @@ Function Invoke-GiteaFileDownload {
# Separate the URL into its components: Gitea URL, Repo Owner, Repo Name, branch, file path, and file name # Separate the URL into its components: Gitea URL, Repo Owner, Repo Name, branch, file path, and file name
$uri = New-Object System.Uri($downloadURL) $uri = New-Object System.Uri($downloadURL)
$pathSegments = $uri.AbsolutePath.Trim('/').Split('/') $pathSegments = $uri.AbsolutePath.Trim('/').Split('/')
# Everything after the branch + 1 segment is considered the file path with the last segment being the file name If($type -eq "lfs") {
$branchIndex = [Array]::IndexOf($pathSegments, "branch") + 2 # Everything after the media segment is considered the file path with the last segment being the file name
$DownloadFilePath = $pathSegments[$branchIndex..($pathSegments.Length - 2)] -join '/' $branchIndex = [Array]::IndexOf($pathSegments, "media") + 1
$DownloadFileName = $pathSegments[-1] $DownloadFilePath = $pathSegments[$branchIndex..($pathSegments.Length - 2)] -join '/'
$DownloadFileName = $pathSegments[-1]
}
Else {
# Everything after the branch + 1 segment is considered the file path with the last segment being the file name
$branchIndex = [Array]::IndexOf($pathSegments, "branch") + 2
$DownloadFilePath = $pathSegments[$branchIndex..($pathSegments.Length - 2)] -join '/'
$DownloadFileName = $pathSegments[-1]
}
if ($PreserveRelativePath -and $outputPath) { if ($PreserveRelativePath -and $outputPath) {
# If PreserveRelativePath is used, set up the directory structure # If PreserveRelativePath is used, set up the directory structure