From 409896fe3a5f6e6ddb1edd7758deca3f01502916 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 10 Jun 2026 12:27:47 -0400 Subject: [PATCH 1/2] feat: customize IPM load flags used by pull event handlers --- CHANGELOG.md | 1 + .../Git/PullEventHandler/PackageManager.cls | 21 ++++++++++ .../PullEventHandler/PackageManagerReload.cls | 9 ++-- .../PullEventHandler/PackageManagerReload.cls | 41 +++++++++++++++++++ test/_resources/simplest-module/module.xml | 10 +++++ 5 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls create mode 100644 test/_resources/simplest-module/module.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 27465f59..9ea2c9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change context menu now lists IPM packages from all Git-enabled namespaces, prefixed with the namespace name (#952) - Pull event handler option in settings page now displays user-friendly names for options (#908) - Validation that SSH key file path is not a directory when configuring Embedded Git (#943) +- Customization of IPM load flags using `##class(SourceControl.Git.PullEventHandler.PackageManager).ConfigureLoadFlags(.flags)` (#974) ### Fixed - Changes to % routines mapped to the current namespace may now be added to source control and committed (#944) diff --git a/cls/SourceControl/Git/PullEventHandler/PackageManager.cls b/cls/SourceControl/Git/PullEventHandler/PackageManager.cls index 42c39f87..dec52259 100644 --- a/cls/SourceControl/Git/PullEventHandler/PackageManager.cls +++ b/cls/SourceControl/Git/PullEventHandler/PackageManager.cls @@ -9,10 +9,31 @@ Parameter DESCRIPTION = "Does zpm ""load """; Method OnPull() As %Status { set command = "load "_..LocalRoot + set key = $order(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags","")) + while (key '= "") { + set command = command _ " -" _ $zstrip(key,"*W") _ "=" _ $zstrip(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key),"*W") + set key = $order(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key)) + } quit $select( $$$comClassDefined("%IPM.Main"): ##class(%IPM.Main).Shell(command), 1: ##class(%ZPM.PackageManager).Shell(command) ) } +/// Configures additional flags to be used with zpm "load" by Package Manager pull event handlers +/// Example: to use `zpm "load -DNoMapping=1"` run the following: +/// ``` +/// kill flags set flags("DNoMapping") = 1 +/// do ##class(SourceControl.Git.PullEventHandler.PackageManager).ConfigureLoadFlags(.flags) +/// ``` +ClassMethod ConfigureLoadFlags(ByRef flags) +{ + kill @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags") + set key = $order(flags("")) + while (key '= "") { + set @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key) = flags(key) + set key = $order(flags(key)) + } +} + } diff --git a/cls/SourceControl/Git/PullEventHandler/PackageManagerReload.cls b/cls/SourceControl/Git/PullEventHandler/PackageManagerReload.cls index 87cb3f5d..29f480be 100644 --- a/cls/SourceControl/Git/PullEventHandler/PackageManagerReload.cls +++ b/cls/SourceControl/Git/PullEventHandler/PackageManagerReload.cls @@ -1,4 +1,4 @@ -Class SourceControl.Git.PullEventHandler.PackageManagerReload Extends SourceControl.Git.PullEventHandler +Class SourceControl.Git.PullEventHandler.PackageManagerReload Extends SourceControl.Git.PullEventHandler.PackageManager { Parameter NAME = "Package Manager Reload"; @@ -20,11 +20,8 @@ Method OnPull() As %Status ) $$$QuitOnError(sc) } - set command = "load "_..LocalRoot - quit $select( - $$$comClassDefined("%IPM.Main"): ##class(%IPM.Main).Shell(command), - 1: ##class(%ZPM.PackageManager).Shell(command) - ) + /// super class loads the IPM package + return ##super() } } diff --git a/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls b/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls new file mode 100644 index 00000000..164bce75 --- /dev/null +++ b/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls @@ -0,0 +1,41 @@ +/// integration tests for the Package Manager Reload pull event handler +Class UnitTest.SourceControl.Git.PullEventHandler.PackageManagerReload Extends UnitTest.SourceControl.Git.AbstractTest +{ + +Method TestLoadUninstallsThenInstalls() +{ + set testModulePath = ##class(SourceControl.Git.PackageManagerContext).ForInternalName("git-source-control.zpm").Package.Root_"test/_resources/simplest-module" + set pullEventHandler = ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).%New() + set pullEventHandler.LocalRoot = testModulePath + // pull once to install simplest-module + do $$$AssertStatusOK(pullEventHandler.OnPull()) + // pull again to verify uninstall + install + do $$$AssertStatusOK(pullEventHandler.OnPull()) + set history = ##class(%IPM.General.History).GetHistory(,,2) + do $$$AssertTrue(history.%Next()) + do $$$AssertEquals(history.Action,"load") + do $$$AssertTrue(history.%Next()) + do $$$AssertEquals(history.Action,"uninstall") + do $$$AssertEquals(history.CommandString,"uninstall simplest-module") + zpm "uninstall simplest-module" +} + +Method TestLoadUsesConfiguredFlags() +{ + set testModulePath = ##class(SourceControl.Git.PackageManagerContext).ForInternalName("git-source-control.zpm").Package.Root_"test/_resources/simplest-module" + kill initFlags + merge initFlags = @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags") + kill flags set flags("DNoMapping") = 1 + do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(.flags) + set pullEventHandler = ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).%New() + set pullEventHandler.LocalRoot = testModulePath + do $$$AssertStatusOK(pullEventHandler.OnPull()) + set history = ##class(%IPM.General.History).GetHistory(,,2) + do $$$AssertTrue(history.%Next()) + do $$$AssertEquals(history.Action,"load") + do $$$AssertEquals(history.CommandString, "load "_testModulePath_" -DNoMapping=1") + zpm "uninstall simplest-module" + do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(.initFlags) +} + +} diff --git a/test/_resources/simplest-module/module.xml b/test/_resources/simplest-module/module.xml new file mode 100644 index 00000000..6fbd0e42 --- /dev/null +++ b/test/_resources/simplest-module/module.xml @@ -0,0 +1,10 @@ + + + + + simplest-module + 1.0.0 + module + + + From ceb44c71b8613ec92aa8c8f16d839b8e9ae7e7d4 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Fri, 12 Jun 2026 11:27:19 -0400 Subject: [PATCH 2/2] IPM load flags no longer enforces a key=value format --- .../Git/PullEventHandler/PackageManager.cls | 24 ++++++++----------- .../PullEventHandler/PackageManagerReload.cls | 11 ++++----- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/cls/SourceControl/Git/PullEventHandler/PackageManager.cls b/cls/SourceControl/Git/PullEventHandler/PackageManager.cls index dec52259..77a4a6f3 100644 --- a/cls/SourceControl/Git/PullEventHandler/PackageManager.cls +++ b/cls/SourceControl/Git/PullEventHandler/PackageManager.cls @@ -9,11 +9,8 @@ Parameter DESCRIPTION = "Does zpm ""load """; Method OnPull() As %Status { set command = "load "_..LocalRoot - set key = $order(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags","")) - while (key '= "") { - set command = command _ " -" _ $zstrip(key,"*W") _ "=" _ $zstrip(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key),"*W") - set key = $order(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key)) - } + set additionalFlags = ..GetLoadFlags() + if (additionalFlags'="") set command = command _ " " _ additionalFlags quit $select( $$$comClassDefined("%IPM.Main"): ##class(%IPM.Main).Shell(command), 1: ##class(%ZPM.PackageManager).Shell(command) @@ -23,17 +20,16 @@ Method OnPull() As %Status /// Configures additional flags to be used with zpm "load" by Package Manager pull event handlers /// Example: to use `zpm "load -DNoMapping=1"` run the following: /// ``` -/// kill flags set flags("DNoMapping") = 1 -/// do ##class(SourceControl.Git.PullEventHandler.PackageManager).ConfigureLoadFlags(.flags) +/// do ##class(SourceControl.Git.PullEventHandler.PackageManager).ConfigureLoadFlags("-DNoMapping=1") /// ``` -ClassMethod ConfigureLoadFlags(ByRef flags) +ClassMethod ConfigureLoadFlags(flags = "") { - kill @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags") - set key = $order(flags("")) - while (key '= "") { - set @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags",key) = flags(key) - set key = $order(flags(key)) - } + set @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags") = flags +} + +ClassMethod GetLoadFlags() As %String +{ + return $get(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags")) } } diff --git a/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls b/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls index 164bce75..e063e98b 100644 --- a/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls +++ b/test/UnitTest/SourceControl/Git/PullEventHandler/PackageManagerReload.cls @@ -23,19 +23,18 @@ Method TestLoadUninstallsThenInstalls() Method TestLoadUsesConfiguredFlags() { set testModulePath = ##class(SourceControl.Git.PackageManagerContext).ForInternalName("git-source-control.zpm").Package.Root_"test/_resources/simplest-module" - kill initFlags - merge initFlags = @##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags") - kill flags set flags("DNoMapping") = 1 - do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(.flags) + set initFlags = $get(@##class(SourceControl.Git.Utils).#Storage@("settings","IPM","loadFlags")) + set flags = "-DNoMapping=1 -extra-pip-flags ""--timeout 30""" + do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(flags) set pullEventHandler = ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).%New() set pullEventHandler.LocalRoot = testModulePath do $$$AssertStatusOK(pullEventHandler.OnPull()) set history = ##class(%IPM.General.History).GetHistory(,,2) do $$$AssertTrue(history.%Next()) do $$$AssertEquals(history.Action,"load") - do $$$AssertEquals(history.CommandString, "load "_testModulePath_" -DNoMapping=1") + do $$$AssertEquals(history.CommandString, "load "_testModulePath_" -DNoMapping=1 -extra-pip-flags ""--timeout 30""") zpm "uninstall simplest-module" - do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(.initFlags) + do ##class(SourceControl.Git.PullEventHandler.PackageManagerReload).ConfigureLoadFlags(initFlags) } }