Skip to content

Commit 4d02319

Browse files
committed
compile on import using pull event handler
1 parent 31ea12b commit 4d02319

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Command-line utility to do a baseline export of items in a namespace
2020
- 'New Branch' menu option in basic now will create new branches from the configured default merge branch (#366)
2121
- Merging back with the default merge branch is now a part of the basic mode's Sync flow (#366)
22+
- Added a new option "compileOnImport". If true, Import options will compile files using the pull event handler. (#362)
2223

2324
### Fixed
2425
- Modifications to local repo files are now synced with IRIS (#153)

cls/SourceControl/Git/Settings.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Property systemBasicMode As %Boolean [ InitialExpression = {##class(SourceContro
4444
/// In Basic mode, Sync will merge changes from this remote branch
4545
Property defaultMergeBranch As %String [ InitialExpression = {##class(SourceControl.Git.Utils).DefaultMergeBranch()} ];
4646

47+
/// Import All options compile imported options using the configured pull event handler
48+
Property compileOnImport As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).CompileOnImport()} ];
49+
4750
Property Mappings [ MultiDimensional ];
4851

4952
Method %OnNew() As %Status
@@ -97,6 +100,7 @@ Method %Save() As %Status
97100
set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly
98101
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly
99102
set @storage@("settings", "defaultMergeBranch") = ..defaultMergeBranch
103+
set @storage@("settings", "compileOnImport") = ..compileOnImport
100104
set @storage@("settings", "basicMode") = ..systemBasicMode
101105
if ..basicMode = "system" {
102106
kill @storage@("settings", "user", $username, "basicMode")
@@ -206,4 +210,3 @@ Method OnAfterConfigure() As %Boolean
206210
}
207211

208212
}
209-

cls/SourceControl/Git/Utils.cls

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ ClassMethod PrivateKeyFile() As %String
153153
quit $get(@..#Storage@("settings","ssh","privateKeyFile"))
154154
}
155155

156+
ClassMethod CompileOnImport() As %Boolean
157+
{
158+
quit $get(@..#Storage@("settings","compileOnImport"),1)
159+
}
160+
156161
ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ]
157162
{
158163
(..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """")
@@ -1294,13 +1299,17 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
12941299

12951300
#dim ec as %Status = ..ListItemsInFiles(.itemList, .err)
12961301
quit:'ec ec
1302+
1303+
kill files
12971304

1305+
set settings = ##class(SourceControl.Git.Settings).%New()
12981306
#dim internalName as %String = ""
12991307
for {
13001308
set internalName = $order(itemList(internalName))
13011309
quit:internalName=""
13021310
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(internalName)
13031311
continue:context.Package'=refPackage
1312+
set doImport = ..IsRoutineOutdated(internalName) || force
13041313
if ..IsInSourceControl(internalName) {
13051314
set sc = ..ImportItem(internalName, force)
13061315
} else {
@@ -1309,6 +1318,21 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
13091318
if $$$ISERR(sc) {
13101319
set ec = $$$ADDSC(ec, sc)
13111320
}
1321+
if doImport && settings.compileOnImport {
1322+
set modification = ##class(SourceControl.Git.Modification).%New()
1323+
set modification.changeType = "M"
1324+
set modification.internalName = internalName
1325+
set modification.externalName = ..FullExternalName(internalName)
1326+
set files($increment(files)) = modification
1327+
}
1328+
}
1329+
1330+
set eventHandler = $classmethod(..PullEventClass(),"%New")
1331+
set eventHandler.LocalRoot = ..TempFolder()
1332+
merge eventHandler.ModifiedFiles = files
1333+
set sc = eventHandler.OnPull()
1334+
if $$$ISERR(sc) {
1335+
set ec = $$$ADDSC(ec,sc)
13121336
}
13131337

13141338
//let's delete all items for which corresponding files had been deleted

csp/gitprojectsettings.csp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ body {
9090
set settings.mappedItemsReadOnly = 0
9191
}
9292

93+
set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1)
94+
9395
if ($Get(%request.Data("basicMode", 1)) = 1) {
9496
set settings.basicMode = 1
9597
} elseif ($Get(%request.Data("basicMode", 1)) = "system"){
@@ -336,6 +338,16 @@ body {
336338

337339

338340
</div>
341+
<div class="form-group row mb-3">
342+
<label for="compileOnImport" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="If true, the Import All options will compile imported options using the configured pull event handler">Compile Items on Import</label>
343+
<div class="col-sm-7">
344+
<div class="custom-control custom-switch custom-switch-no-border">
345+
<input class="custom-control-input" name="compileOnImport" type="checkbox"
346+
id="compileOnImport" #($select(settings.compileOnImport:"checked",1:""))# value="1">
347+
<label class="custom-control-label" for="compileOnImport"></label>
348+
</div>
349+
</div>
350+
</div>
339351

340352
<div class="form-group row mb-3 mapping-input-group">
341353
<div class="offset-sm-1 col-sm-3">

0 commit comments

Comments
 (0)