Skip to content

Commit 1339585

Browse files
committed
export and add ignore mapped files
1 parent 24ae01e commit 1339585

File tree

4 files changed

+9631
-26
lines changed

4 files changed

+9631
-26
lines changed

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: 25 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+
if (settings.mappedItemsReadOnly && FileIsMapped(InternalName)) {
535+
continue
536+
}
537+
538+
// SKIP IF A MAPPED ITEM
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,11 @@ 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+
if (..FileIsMapped(InternalName) && settings.mappedItemsReadOnly) {
1369+
write "Skipping export since mapping to another database found."
1370+
quit $$$OK
1371+
}
13521372
set filenames($I(filenames)) = filename
13531373
write !, "exporting new version of ", InternalName, " to ", filename
13541374
$$$QuitOnError($system.OBJ.ExportUDL(InternalName, filename,"-d/diff"))
@@ -1689,6 +1709,11 @@ ClassMethod UserTypeCached(Name As %String, ByRef Class As %String, ByRef Studio
16891709
Quit 1
16901710
}
16911711

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

csp/gitprojectsettings.csp

Lines changed: 45 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,13 @@ 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+
}
83+
set ^mtemphw($i(^mtemphw)) = $get(%request.Data("mappedItemsReadOnly", 1))
7384
set i = 1
7485
set param = "NoFolders"
7586
kill settings.Mappings
@@ -93,8 +104,7 @@ body {
93104
<input type="hidden" name="gitsettings" value="1" />
94105
<div class="col-sm-12"><br></div>
95106
<div class="row">
96-
<div class="col-sm-1"></div>
97-
<div class="col-sm-8">
107+
<div class="offset-sm-1 col-sm-8">
98108
<h1>Git Project Settings</h1>
99109
</div>
100110
<div class="col-sm-2">
@@ -110,16 +120,14 @@ body {
110120
<div class="col-md-10"><hr></div>
111121
</div>
112122
<div class="row">
113-
<div class="col-sm-1"></div>
114-
<div class="col-sm-11">
123+
<div class="offset-sm-1 col-sm-11">
115124
<h3>Settings for namespace #(..EscapeHTML(namespace))# #($select(settings.settingsUIReadOnly:"(read-only)",1:""))#</h3><br/>
116125
</div>
117126
</div>
118127

119128
<fieldset id="namespaceSettings">
120129
<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>
130+
<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>
123131
<div class="col-sm-7">
124132
<server>
125133
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
@@ -152,8 +160,7 @@ body {
152160
</div>
153161

154162
<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>
163+
<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>
157164
<server>
158165
set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp)
159166
if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") {
@@ -171,8 +178,7 @@ body {
171178
if (settings.namespaceTemp '= "") && '##class(%File).DirectoryExists(dir_".git") {
172179
&html<
173180
<div class="form-group row mb-3">
174-
<div class="col-sm-4"></div>
175-
<div class="col-sm-8 neutral-feedback">
181+
<div class="offset-sm-4 col-sm-8 neutral-feedback">
176182
<span id="initMsg">Git has not been not initialized for folder.</span>
177183
<button id="initBtn" onclick="init(); return false;" class="btn btn-sm btn-outline-dark">Initialize</button>
178184
<button id="cloneBtn" onclick="clone(); return false;" class="btn btn-sm btn-outline-dark">Clone...</button>
@@ -183,8 +189,7 @@ body {
183189
}
184190
</server>
185191
<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>
192+
<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>
188193
<div class="col-sm-7">
189194
<server>
190195
Set fileExists = ##class(%File).Exists(settings.privateKeyFile)
@@ -223,8 +228,7 @@ body {
223228
}
224229
&html<
225230
<div class="form-group row mb-3">
226-
<div class="col-sm-1"></div>
227-
<div class="col-sm-3">Public key:</div>
231+
<div class="offset-sm-1 col-sm-3">Public key:</div>
228232
<div class="col-sm-5">
229233
<pre id="publicKey">#(pubKeyText)#</pre>
230234
</div>
@@ -238,8 +242,7 @@ body {
238242
</server>
239243

240244
<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>
245+
<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>
243246
<div class="col-sm-7">
244247
<select class="form-control" id="pullEventClass" name="pullEventClass">
245248
<server>
@@ -255,16 +258,36 @@ body {
255258
</div>
256259

257260
<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>
261+
<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>
260262
<div class="col-sm-7">
261263
<input type="text" class="form-control" id="percentClassReplace" name="percentClassReplace" value='#(..EscapeHTML(settings.percentClassReplace))#' placeholder="_, __, <empty>, etc."/>
262264
</div>
263265
</div>
266+
267+
268+
<div class="form-group row mb-3">
269+
<label for="mappedItemsReadOnly" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Whether items mapped from another 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>
270+
<div class="col-sm-7">
271+
272+
<div class="custom-control custom-switch custom-switch-no-border">
273+
<server>
274+
if (settings.mappedItemsReadOnly) {
275+
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" checked value="1">>
276+
} else {
277+
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" value="1">>
278+
}
279+
</server>
280+
281+
<label class="custom-control-label" for="mappedItemsReadOnly"></label>
282+
</div>
283+
284+
</div>
285+
264286

287+
</div>
288+
265289
<div class="form-group row mb-3 mapping-input-group">
266-
<div class="col-sm-1"></div>
267-
<div class="col-sm-3">
290+
<div class="offset-sm-1 col-sm-3">
268291
<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>
269292
<button type="button" class="btn btn-default btn-add" >
270293
<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 +391,14 @@ body {
368391

369392
<fieldset id="userSettings">
370393
<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>
394+
<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>
373395
<div class="col-sm-7">
374396
<input type="text" class="form-control" id="gitUserName" name="gitUserName" value='#(..EscapeHTML(settings.gitUserName))#'/>
375397
</div>
376398
</div>
377399

378400
<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>
401+
<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>
381402
<div class="col-sm-7">
382403
<input type="email" class="form-control" id="gitUserEmail" name="gitUserEmail" value='#(..EscapeHTML(settings.gitUserEmail))#'/>
383404
</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)