Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #189 Export and Add ignore mapped #345

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [2.4.0] - Unreleased

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

## [2.3.1] - 2024-04-30

Expand Down
1 change: 1 addition & 0 deletions cls/SourceControl/Git/Change.cls
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,4 @@ Storage Default
}

}

5 changes: 5 additions & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Property gitUserName As %String(MAXLEN = 255) [ InitialExpression = {##class(Sou
/// Attribution: Email address for user ${username}
Property gitUserEmail As %String(MAXLEN = 255) [ InitialExpression = {##class(SourceControl.Git.Utils).GitUserEmail()} ];

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

Property Mappings [ MultiDimensional ];

Method %OnNew() As %Status
Expand Down Expand Up @@ -80,6 +83,7 @@ Method %Save() As %Status
set @storage@("settings","pullEventClass") = ..pullEventClass
set @storage@("settings","percentClassReplace") = ..percentClassReplace
set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly

kill @##class(SourceControl.Git.Utils).MappingsNode()
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
Expand Down Expand Up @@ -109,6 +113,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }")
do %code.WriteLine(" set inst."_property_" = value")

}
do %code.WriteLine(" $$$ThrowOnError(inst.%Save())")
do %code.WriteLine(" write !,""Settings saved.""")
Expand Down
27 changes: 27 additions & 0 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ ClassMethod GitBinPath(Output isDefault) As %String
quit $case($extract(binPath),"""":binPath,:""""_binPath_"""")
}

ClassMethod MappedItemsReadOnly() As %Boolean
{
quit $get(@..#Storage@("settings", "mappedItemsReadOnly"), 1)
}

ClassMethod GitUserName() As %String
{
quit $get(@..#Storage@("settings","user",$username,"gitUserName"),$username)
Expand Down Expand Up @@ -508,6 +513,7 @@ ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status

ClassMethod AddToSourceControl(InternalName As %String) As %Status
{
set settings = ##class(SourceControl.Git.Settings).%New()
#dim i as %Integer
#dim ec as %Status = $$$OK
for i = 1:1:$length(InternalName, ",") {
Expand All @@ -518,11 +524,18 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
if 'sc {
set ec = $$$ADDSC(ec, sc)
}

for i=1:1:$Get(filenames) {
set FileInternalName = ##class(SourceControl.Git.Utils).NormalizeExtension(##class(SourceControl.Git.Utils).NameToInternalName(filenames(i), 0,,1))
if (FileInternalName = "") {
continue
}

// Items mapped to namespace's non default routine database are ignored if set to be read-only
if (settings.mappedItemsReadOnly && ..FileIsMapped(InternalName)) {
continue
}

set FileType = ##class(SourceControl.Git.Utils).Type(.FileInternalName)

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

ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0, ByRef filenames) As %Status
{
set settings = ##class(SourceControl.Git.Settings).%New()

#dim type = ..Type(.InternalName)
if type = "pkg" {
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force, .filenames))
Expand All @@ -1349,6 +1364,12 @@ ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As
write "Did not find a matching mapping for """_InternalName_""". Skipping export."
quit $$$OK
}

// Items mapped to namespace's non default routine database are ignored if set to be read-only
if (..FileIsMapped(InternalName) && settings.mappedItemsReadOnly) {
write "Mapping to another database found. Skipping export"
quit $$$OK
}
set filenames($I(filenames)) = filename
write !, "exporting new version of ", InternalName, " to ", filename
$$$QuitOnError($system.OBJ.ExportUDL(InternalName, filename,"-d/diff"))
Expand Down Expand Up @@ -1689,6 +1710,12 @@ ClassMethod UserTypeCached(Name As %String, ByRef Class As %String, ByRef Studio
Quit 1
}

/// Determines whether or not a file is mapped to another database
ClassMethod FileIsMapped(InternalName As %String) As %Boolean
{
Quit ##class(%RoutineMgr).IsMapped(InternalName)
}

/*
NameToInternalName(name): given a Unix-style slash path relative to repo root,
returns the internal name for that file (e.g., cls/SourceControl/Git/Utils.cls -> SourceControl.Git.Utils.CLS)
Expand Down
68 changes: 44 additions & 24 deletions csp/gitprojectsettings.csp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ body {
border-left: 0px;
}

.custom-switch-no-border {
border: 0px;
}

.neutral-feedback {
width: 100%;
margin-top: 0.25rem;
Expand All @@ -70,6 +74,12 @@ body {
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace" {
set $Property(settings,param) = $Get(%request.Data(param,1))
}

if ($Get(%request.Data("mappedItemsReadOnly", 1)) = 1) {
set settings.mappedItemsReadOnly = 1
} else {
set settings.mappedItemsReadOnly = 0
}
set i = 1
set param = "NoFolders"
kill settings.Mappings
Expand All @@ -93,8 +103,7 @@ body {
<input type="hidden" name="gitsettings" value="1" />
<div class="col-sm-12"><br></div>
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-8">
<div class="offset-sm-1 col-sm-8">
isc-tleavitt marked this conversation as resolved.
Show resolved Hide resolved
<h1>Git Project Settings</h1>
</div>
<div class="col-sm-2">
Expand All @@ -110,16 +119,14 @@ body {
<div class="col-md-10"><hr></div>
</div>
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-11">
<div class="offset-sm-1 col-sm-11">
<h3>Settings for namespace #(..EscapeHTML(namespace))# #($select(settings.settingsUIReadOnly:"(read-only)",1:""))#</h3><br/>
</div>
</div>

<fieldset id="namespaceSettings">
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<div class="col-sm-7">
<server>
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
Expand Down Expand Up @@ -152,8 +159,7 @@ body {
</div>

<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<server>
set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp)
if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") {
Expand All @@ -171,8 +177,7 @@ body {
if (settings.namespaceTemp '= "") && '##class(%File).DirectoryExists(dir_".git") {
&html<
<div class="form-group row mb-3">
<div class="col-sm-4"></div>
<div class="col-sm-8 neutral-feedback">
<div class="offset-sm-4 col-sm-8 neutral-feedback">
<span id="initMsg">Git has not been not initialized for folder.</span>
<button id="initBtn" onclick="init(); return false;" class="btn btn-sm btn-outline-dark">Initialize</button>
<button id="cloneBtn" onclick="clone(); return false;" class="btn btn-sm btn-outline-dark">Clone...</button>
Expand All @@ -183,8 +188,7 @@ body {
}
</server>
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<div class="col-sm-7">
<server>
Set fileExists = ##class(%File).Exists(settings.privateKeyFile)
Expand Down Expand Up @@ -223,8 +227,7 @@ body {
}
&html<
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<div class="col-sm-3">Public key:</div>
<div class="offset-sm-1 col-sm-3">Public key:</div>
<div class="col-sm-5">
<pre id="publicKey">#(pubKeyText)#</pre>
</div>
Expand All @@ -238,8 +241,7 @@ body {
</server>

<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<div class="col-sm-7">
<select class="form-control" id="pullEventClass" name="pullEventClass">
<server>
Expand All @@ -255,16 +257,36 @@ body {
</div>

<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<div class="col-sm-7">
<input type="text" class="form-control" id="percentClassReplace" name="percentClassReplace" value='#(..EscapeHTML(settings.percentClassReplace))#' placeholder="_, __, <empty>, etc."/>
</div>
</div>


<div class="form-group row mb-3">
<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>
<div class="col-sm-7">

<div class="custom-control custom-switch custom-switch-no-border">
<server>
if (settings.mappedItemsReadOnly) {
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" checked value="1">>
} else {
&html<<input class="custom-control-input" name="mappedItemsReadOnly" type="checkbox" id="mappedItemsReadOnly" value="1">>
}
</server>

<label class="custom-control-label" for="mappedItemsReadOnly"></label>
</div>

</div>


</div>

<div class="form-group row mb-3 mapping-input-group">
<div class="col-sm-1"></div>
<div class="col-sm-3">
<div class="offset-sm-1 col-sm-3">
<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>
<button type="button" class="btn btn-default btn-add" >
<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">
Expand Down Expand Up @@ -368,16 +390,14 @@ body {

<fieldset id="userSettings">
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<label for="gitUserName" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Firstname Lastname">Git Committer Name </label>
<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>
<div class="col-sm-7">
<input type="text" class="form-control" id="gitUserName" name="gitUserName" value='#(..EscapeHTML(settings.gitUserName))#'/>
</div>
</div>

<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<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>
<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>
<div class="col-sm-7">
<input type="email" class="form-control" id="gitUserEmail" name="gitUserEmail" value='#(..EscapeHTML(settings.gitUserEmail))#'/>
</div>
Expand Down
9,558 changes: 9,556 additions & 2 deletions git-webui/release/share/git-webui/webui/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading