func_Repository.ps1

# ---------------------------------------------------------------------
# Repository files API
# https://docs.gitlab.com/ee/api/repository_files.html

# get raw file from repository
function Get-GitlabRepositoryFileRaw( [Parameter(Mandatory=$true)] [string] $project
                                    , [Parameter(Mandatory=$true)] [string] $file_path
                                    , [Parameter(Mandatory=$false)][string] $ref
                                    , [Parameter(Mandatory=$false)][switch] $lfs
                                    )
{
  $file_path = [uri]::EscapeDataString($file_path)
  [string] $GAPI_FILES_ID = "$CI_API_V4_URL/projects/$project/repository/files/$file_path/raw"

  if (![string]::IsNullOrWhiteSpace($ref)) {
    $ref = [uri]::EscapeDataString($ref)
    $GAPI_FILES_ID += "?ref=$ref"

    if ($lfs) {
      $GAPI_FILES_ID += "&lfs=true"
    }
  }

  return (Invoke-RestMethod -headers $GLPT -uri $GAPI_FILES_ID -method GET)
}