Skip to content

Commit c6cbad3

Browse files
authored
Merge pull request #345 from intersystems/export-ignore-mapped
Fixes #189 Export and Add ignore mapped
2 parents 2ab0213 + 6e71e16 commit c6cbad3

File tree

6 files changed

+9636
-26
lines changed

6 files changed

+9636
-26
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
89
## [2.4.0] - Unreleased
910

1011
### Added
1112
- Pre-release support for IPM v0.9.0+
13+
- Items mapped from database other than namespace's default routine database are now ignored by default when exporting or adding files
14+
- New setting to configure whether mapped items should be should be treated as read-only
1215

1316
## [2.3.1] - 2024-04-30
1417

cls/SourceControl/Git/Change.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,4 @@ Storage Default
217217
}
218218

219219
}
220+

cls/SourceControl/Git/Settings.cls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Property gitUserName As %String(MAXLEN = 255) [ InitialExpression = {##class(Sou
2929
/// Attribution: Email address for user ${username}
3030
Property gitUserEmail As %String(MAXLEN = 255) [ InitialExpression = {##class(SourceControl.Git.Utils).GitUserEmail()} ];
3131

32+
/// Attribution: Whether mapped items should be read-only, preventing them from being added to source control
33+
Property mappedItemsReadOnly As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).MappedItemsReadOnly()} ];
34+
3235
Property Mappings [ MultiDimensional ];
3336

3437
Method %OnNew() As %Status
@@ -80,6 +83,7 @@ Method %Save() As %Status
8083
set @storage@("settings","pullEventClass") = ..pullEventClass
8184
set @storage@("settings","percentClassReplace") = ..percentClassReplace
8285
set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly
86+
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly
8387

8488
kill @##class(SourceControl.Git.Utils).MappingsNode()
8589
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
@@ -109,6 +113,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
109113
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
110114
do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }")
111115
do %code.WriteLine(" set inst."_property_" = value")
116+
112117
}
113118
do %code.WriteLine(" $$$ThrowOnError(inst.%Save())")
114119
do %code.WriteLine(" write !,""Settings saved.""")

cls/SourceControl/Git/Utils.cls

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ ClassMethod GitBinPath(Output isDefault) As %String
113113
quit $case($extract(binPath),"""":binPath,:""""_binPath_"""")
114114
}
115115

116+
ClassMethod MappedItemsReadOnly() As %Boolean
117+
{
118+
quit $get(@..#Storage@("settings", "mappedItemsReadOnly"), 1)
119+
}
120+
116121
ClassMethod GitUserName() As %String
117122
{
118123
quit $get(@..#Storage@("settings","user",$username,"gitUserName"),$username)
@@ -508,6 +513,7 @@ ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
508513

509514
ClassMethod AddToSourceControl(InternalName As %String) As %Status
510515
{
516+
set settings = ##class(SourceControl.Git.Settings).%New()
511517
#dim i as %Integer
512518
#dim ec as %Status = $$$OK
513519
for i = 1:1:$length(InternalName, ",") {
@@ -518,11 +524,18 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
518524
if 'sc {
519525
set ec = $$$ADDSC(ec, sc)
520526
}
527+
521528
for i=1:1:$Get(filenames) {
522529
set FileInternalName = ##class(SourceControl.Git.Utils).NormalizeExtension(##class(SourceControl.Git.Utils).NameToInternalName(filenames(i), 0,,1))
523530
if (FileInternalName = "") {
524531
continue
525532
}
533+
534+
// Items mapped to namespace's non default routine database are ignored if set to be read-only
535+
if (settings.mappedItemsReadOnly && ..FileIsMapped(InternalName)) {
536+
continue
537+
}
538+
526539
set FileType = ##class(SourceControl.Git.Utils).Type(.FileInternalName)
527540

528541
set @..#Storage@("items", FileInternalName) = ""
@@ -1334,6 +1347,8 @@ ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %In
13341347

13351348
ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0, ByRef filenames) As %Status
13361349
{
1350+
set settings = ##class(SourceControl.Git.Settings).%New()
1351+
13371352
#dim type = ..Type(.InternalName)
13381353
if type = "pkg" {
13391354
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force, .filenames))
@@ -1349,6 +1364,12 @@ ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As
13491364
write "Did not find a matching mapping for """_InternalName_""". Skipping export."
13501365
quit $$$OK
13511366
}
1367+
1368+
// Items mapped to namespace's non default routine database are ignored if set to be read-only
1369+
if (..FileIsMapped(InternalName) && settings.mappedItemsReadOnly) {
1370+
write "Mapping to another database found. Skipping export"
1371+
quit $$$OK
1372+
}
13521373
set filenames($I(filenames)) = filename
13531374
write !, "exporting new version of ", InternalName, " to ", filename
13541375
$$$QuitOnError($system.OBJ.ExportUDL(InternalName, filename,"-d/diff"))
@@ -1689,6 +1710,12 @@ ClassMethod UserTypeCached(Name As %String, ByRef Class As %String, ByRef Studio
16891710
Quit 1
16901711
}
16911712

1713+
/// Determines whether or not a file is mapped to another database
1714+
ClassMethod FileIsMapped(InternalName As %String) As %Boolean
1715+
{
1716+
Quit ##class(%RoutineMgr).IsMapped(InternalName)
1717+
}
1718+
16921719
/*
16931720
NameToInternalName(name): given a Unix-style slash path relative to repo root,
16941721
returns the internal name for that file (e.g., cls/SourceControl/Git/Utils.cls -> SourceControl.Git.Utils.CLS)

csp/gitprojectsettings.csp

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ body {
4747
border-left: 0px;
4848
}
4949

50+
.custom-switch-no-border {
51+
border: 0px;
52+
}
53+
5054
.neutral-feedback {
5155
width: 100%;
5256
margin-top: 0.25rem;
@@ -70,6 +74,12 @@ body {
7074
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace" {
7175
set $Property(settings,param) = $Get(%request.Data(param,1))
7276
}
77+
78+
if ($Get(%request.Data("mappedItemsReadOnly", 1)) = 1) {
79+
set settings.mappedItemsReadOnly = 1
80+
} else {
81+
set settings.mappedItemsReadOnly = 0
82+
}
7383
set i = 1
7484
set param = "NoFolders"
7585
kill settings.Mappings
@@ -93,8 +103,7 @@ body {
93103
<input type="hidden" name="gitsettings" value="1" />
94104
<div class="col-sm-12"><br></div>
95105
<div class="row">
96-
<div class="col-sm-1"></div>
97-
<div class="col-sm-8">
106+
<div class="offset-sm-1 col-sm-8">
98107
<h1>Git Project Settings</h1>
99108
</div>
100109
<div class="col-sm-2">
@@ -110,16 +119,14 @@ body {
110119
<div class="col-md-10"><hr></div>
111120
</div>
112121
<div class="row">
113-
<div class="col-sm-1"></div>
114-
<div class="col-sm-11">
122+
<div class="offset-sm-1 col-sm-11">
115123
<h3>Settings for namespace #(..EscapeHTML(namespace))# #($select(settings.settingsUIReadOnly:"(read-only)",1:""))#</h3><br/>
116124
</div>
117125
</div>
118126

119127
<fieldset id="namespaceSettings">
120128
<div class="form-group row mb-3">
121-
<div class="col-sm-1"></div>
122-
<label for="gitBinPath" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to the Git executable">Path to git.exe</label>
129+
<label for="gitBinPath" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to the Git executable">Path to git.exe</label>
123130
<div class="col-sm-7">
124131
<server>
125132
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
@@ -152,8 +159,7 @@ body {
152159
</div>
153160

154161
<div class="form-group row mb-3">
155-
<div class="col-sm-1"></div>
156-
<label for="namespaceTemp" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to you project">Temp folder for this namespace<br/></label>
162+
<label for="namespaceTemp" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to you project">Temp folder for this namespace<br/></label>
157163
<server>
158164
set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp)
159165
if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") {
@@ -171,8 +177,7 @@ body {
171177
if (settings.namespaceTemp '= "") && '##class(%File).DirectoryExists(dir_".git") {
172178
&html<
173179
<div class="form-group row mb-3">
174-
<div class="col-sm-4"></div>
175-
<div class="col-sm-8 neutral-feedback">
180+
<div class="offset-sm-4 col-sm-8 neutral-feedback">
176181
<span id="initMsg">Git has not been not initialized for folder.</span>
177182
<button id="initBtn" onclick="init(); return false;" class="btn btn-sm btn-outline-dark">Initialize</button>
178183
<button id="cloneBtn" onclick="clone(); return false;" class="btn btn-sm btn-outline-dark">Clone...</button>
@@ -183,8 +188,7 @@ body {
183188
}
184189
</server>
185190
<div class="form-group row mb-3">
186-
<div class="col-sm-1"></div>
187-
<label for="privateKeyFile" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to your private SSH key file">SSH Private Key File</label>
191+
<label for="privateKeyFile" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to your private SSH key file">SSH Private Key File</label>
188192
<div class="col-sm-7">
189193
<server>
190194
Set fileExists = ##class(%File).Exists(settings.privateKeyFile)
@@ -223,8 +227,7 @@ body {
223227
}
224228
&html<
225229
<div class="form-group row mb-3">
226-
<div class="col-sm-1"></div>
227-
<div class="col-sm-3">Public key:</div>
230+
<div class="offset-sm-1 col-sm-3">Public key:</div>
228231
<div class="col-sm-5">
229232
<pre id="publicKey">#(pubKeyText)#</pre>
230233
</div>
@@ -238,8 +241,7 @@ body {
238241
</server>
239242

240243
<div class="form-group row mb-3">
241-
<div class="col-sm-1"></div>
242-
<label for="pullEventClass" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Handler class for git pull">Pull Event Class</label>
244+
<label for="pullEventClass" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Handler class for git pull">Pull Event Class</label>
243245
<div class="col-sm-7">
244246
<select class="form-control" id="pullEventClass" name="pullEventClass">
245247
<server>
@@ -255,16 +257,36 @@ body {
255257
</div>
256258

257259
<div class="form-group row mb-3">
258-
<div class="col-sm-1"></div>
259-
<label for="percentClassReplace" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Character(s) to replace '%' with for percent classes while exporting them out to the filesystem. By default, the '%' is removed.">'%' Replacement on Export</label>
260+
<label for="percentClassReplace" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Character(s) to replace '%' with for percent classes while exporting them out to the filesystem. By default, the '%' is removed.">'%' Replacement on Export</label>
260261
<div class="col-sm-7">
261262
<input type="text" class="form-control" id="percentClassReplace" name="percentClassReplace" value='#(..EscapeHTML(settings.percentClassReplace))#' placeholder="_, __, <empty>, etc."/>
262263
</div>
263264
</div>
265+
266+
267+
<div class="form-group row mb-3">
268+
<label for="mappedItemsReadOnly" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Whether items mapped from a database other than this namespace's default routine database should be read-only. If enabled, mapped items won't be saved to source control or exported. NOTE: These are different from the mappings configured in this settings page"> Treat Mapped Items as Read-only</label>
269+
<div class="col-sm-7">
270+
271+
<div class="custom-control custom-switch custom-switch-no-border">
272+
<server>
273+
if (settings.mappedItemsReadOnly) {
274+
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" checked value="1">>
275+
} else {
276+
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" value="1">>
277+
}
278+
</server>
279+
280+
<label class="custom-control-label" for="mappedItemsReadOnly"></label>
281+
</div>
282+
283+
</div>
284+
264285

286+
</div>
287+
265288
<div class="form-group row mb-3 mapping-input-group">
266-
<div class="col-sm-1"></div>
267-
<div class="col-sm-3">
289+
<div class="offset-sm-1 col-sm-3">
268290
<label for="MappingsPath" class="col-form-label" data-toggle="tooltip" data-placement="top" title="Relative paths mapping the files in your project. For web application files, use the extension: /CSP/">Mappings</label>
269291
<button type="button" class="btn btn-default btn-add" >
270292
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="#198754" class="bi bi-plus-circle-fill" viewBox="0 0 16 16">
@@ -368,16 +390,14 @@ body {
368390

369391
<fieldset id="userSettings">
370392
<div class="form-group row mb-3">
371-
<div class="col-sm-1"></div>
372-
<label for="gitUserName" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Firstname Lastname">Git Committer Name </label>
393+
<label for="gitUserName" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Firstname Lastname">Git Committer Name </label>
373394
<div class="col-sm-7">
374395
<input type="text" class="form-control" id="gitUserName" name="gitUserName" value='#(..EscapeHTML(settings.gitUserName))#'/>
375396
</div>
376397
</div>
377398

378399
<div class="form-group row mb-3">
379-
<div class="col-sm-1"></div>
380-
<label for="gitUserEmail" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="<git-username-on-remote>@remote.com">Git Committer Email </label>
400+
<label for="gitUserEmail" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="<git-username-on-remote>@remote.com">Git Committer Email </label>
381401
<div class="col-sm-7">
382402
<input type="email" class="form-control" id="gitUserEmail" name="gitUserEmail" value='#(..EscapeHTML(settings.gitUserEmail))#'/>
383403
</div>

git-webui/release/share/git-webui/webui/css/bootstrap.min.css

Lines changed: 9556 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)