From c95dedf1a4e5d06aa98a7ce55ac63751bdbcfd21 Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Sat, 7 Oct 2023 09:38:17 +0200 Subject: [PATCH] Fix size problem in invoke-gh (#3205) And do not hide real reason for the error --------- Co-authored-by: freddydk --- Common/Invoke-gh.ps1 | 24 ++++++++++++------------ Common/Invoke-git.ps1 | 21 +++++++++------------ ReleaseNotes.txt | 2 ++ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Common/Invoke-gh.ps1 b/Common/Invoke-gh.ps1 index 3dc00e4c1..a365a13f5 100644 --- a/Common/Invoke-gh.ps1 +++ b/Common/Invoke-gh.ps1 @@ -14,21 +14,21 @@ function invoke-gh { [parameter(mandatory = $false, position = 1, ValueFromRemainingArguments = $true)] $remaining ) - $arguments = "$command " - $remaining | ForEach-Object { - if ("$_".IndexOf(" ") -ge 0 -or "$_".IndexOf('"') -ge 0) { - $arguments += """$($_.Replace('"','\"'))"" " + Process { + $arguments = "$command " + foreach($parameter in $remaining) { + if ("$parameter".IndexOf(" ") -ge 0 -or "$parameter".IndexOf('"') -ge 0) { + if ($parameter.length -gt 15000) { + $parameter = "$($parameter.Substring(0,15000))...`n`n**Truncated due to size limits!**" + } + $arguments += """$($parameter.Replace('"','\"'))"" " + } + else { + $arguments += "$parameter " + } } - else { - $arguments += "$_ " - } - } - try { cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } - catch [System.Management.Automation.MethodInvocationException] { - throw "It looks like GitHub CLI is not installed. Please install GitHub CLI from https://cli.github.com/" - } } Export-ModuleMember -Function Invoke-gh diff --git a/Common/Invoke-git.ps1 b/Common/Invoke-git.ps1 index f959a30a9..a27123b70 100644 --- a/Common/Invoke-git.ps1 +++ b/Common/Invoke-git.ps1 @@ -14,20 +14,17 @@ function invoke-git { [parameter(mandatory = $false, position = 1, ValueFromRemainingArguments = $true)] $remaining ) - $arguments = "$command " - $remaining | ForEach-Object { - if ("$_".IndexOf(" ") -ge 0 -or "$_".IndexOf('"') -ge 0) { - $arguments += """$($_.Replace('"','\"'))"" " + Process { + $arguments = "$command " + foreach($parameter in $remaining) { + if ("$parameter".IndexOf(" ") -ge 0 -or "$parameter".IndexOf('"') -ge 0) { + $arguments += """$($parameter.Replace('"','\"'))"" " + } + else { + $arguments += "$parameter " + } } - else { - $arguments += "$_ " - } - } - try { cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } - catch [System.Management.Automation.MethodInvocationException] { - throw "It looks like Git is not installed. Please install Git from https://git-scm.com/download" - } } Export-ModuleMember -Function Invoke-git diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 2e3be250a..5e56ad3e1 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -4,6 +4,8 @@ The insider SAS token is still supported until April 2024 where the last insider Remove the need for Insider SAS token in Create Container wizard and Create AL-Go repo wizard Add parameter EnableExternalRulesets to Run-AlPipeline (which will be added to the compiler when compiling) Issue https://github.com/microsoft/AL-Go/issues/709 Include unknown app dependencies from previous apps (which doesn't already exist in unknown app dependencies) +Do not hide real exception in invoke-git and invoke-gh +Truncate body part to 15000 characters in invoke-gh 5.0.7 Run-AlValidation also needs to install NAVSIP dependencies (issue #3190)